标签:
Date currentTime = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateString = formatter.format(currentTime);
4.时间加减得到天数
public static long getDaySub(String beginDateStr,String endDateStr)
{
long day=0;
java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("yyyy-MM-dd");
java.util.Date beginDate;
java.util.Date endDate;
try
{
beginDate = format.parse(beginDateStr);
endDate= format.parse(endDateStr);
day=(endDate.getTime()-beginDate.getTime())/(24*60*60*1000);
//System.out.println("相隔的天数="+day);
} catch (ParseException e)
{
// TODO 自动生成 catch 块
e.printStackTrace();
}
return day;
}
标签:
原文地址:http://www.cnblogs.com/it-xiaoJiang/p/5767290.html