java如何计算两个日期之间相差多少天?
public static void main(String [] args) {
Date now = new Date(); Calendar cal = Calendar.getInstance();
cal.set(2015,2,24);
// cal.set(Calendar.YEAR, 2015);
// cal.set(Calendar.MONTH, 2);
// cal.set(Calendar.DATE, 24);
long intervalMills = now.getTime() - cal.getTime().getTime(); long days = intervalMills/(1000*60*60*24); System.out.println(days);
}