/**
* 计算开始时间,结束时间,间隔天数
* @param startDate
* @param endDate
* @return
* @throws ParseException
*/
public static int getDayDiffer(Date startDate, Date endDate) throws ParseException {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
long startDateTime = dateFormat.parse(dateFormat.format(startDate)).getTime();
long endDateTime = dateFormat.parse(dateFormat.format(endDate)).getTime();
return (int) ((endDateTime - startDateTime) / (1000 * 3600 * 24))+1;
}
java根据开始日期和结束日期计算天数
最新推荐文章于 2024-07-26 03:05:11 发布