两个日期相差的天数

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     }

posted on 2014-07-17 15:23  crane_practice  阅读(163)  评论(0编辑  收藏  举报

导航