1 // 两个日期相差的天数 2 public int differDays(String startDateString, String endDateString) 3 throws ParseException { 4 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 5 Date start = sdf.parse(startDateString); 6 Date end = sdf.parse(endDateString); 7 int differ = (int) ((end.getTime() - start.getTime()) / (3600 * 24 * 1000)); 8 return differ; 9 }
两个日期相差的天数
时间: 2024-11-05 01:46:59