得到两个日期的间隔天数(不够一天的按一天算)

/**

* 得到两个日期的间隔天数(不够一天的按一天算)

* @param startDate

* @param endDate

* @return

*/

public static synchronized long daysBetween(Calendar startDate, Calendar endDate) { 

Calendar date = (Calendar) startDate.clone(); 

long daysBetween = 0; 

while (date.before(endDate)) { 

date.add(Calendar.DAY_OF_MONTH, 1); 

daysBetween++;

}

return daysBetween; 

}

展开阅读全文

没有更多推荐了,返回首页