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

/**

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

* @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; 

}

你可能感兴趣的:(calendar,日期,两个,天数,间隔)