public int daysBetween(String dateStr) throws ParseException {
Date today = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date compareDate = sdf.parse(dateStr);
Calendar cal = Calendar.getInstance();
cal.setTime(compareDate);
long time1 = cal.getTimeInMillis();
cal.setTime(today);
long time2 = cal.getTimeInMillis();
long between_days = (time2 - time1) / (1000 * 3600 * 24);
return Integer.parseInt(String.valueOf(between_days));
}
daysBetween
最新推荐文章于 2024-05-13 14:21:50 发布