1 /** 2 * 两个日期之间相差的天数 3 * @param start 4 * @param end 5 * @return 6 */ 7 public static final int daysBetween(Date start, Date end) { 8 java.util.Calendar calst = java.util.Calendar.getInstance(); 9 java.util.Calendar caled = java.util.Calendar.getInstance(); 10 calst.setTime(start); 11 caled.setTime(end); 12 //设置时间为0时 13 calst.set(java.util.Calendar.HOUR_OF_DAY, 0); 14 calst.set(java.util.Calendar.MINUTE, 0); 15 calst.set(java.util.Calendar.SECOND, 0); 16 caled.set(java.util.Calendar.HOUR_OF_DAY, 0); 17 caled.set(java.util.Calendar.MINUTE, 0); 18 caled.set(java.util.Calendar.SECOND, 0); 19 //得到两个日期相差的天数 20 int days = ((int) (caled.getTime().getTime() / 1000) - (int) (calst.getTime().getTime() / 1000)) / 3600 / 24; 21 return days; 22 }