public static boolean inSameDay(Date date1, Date Date2) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date1);
int year1 = calendar.get(Calendar.YEAR);
int day1 = calendar.get(Calendar.DAY_OF_YEAR);
calendar.setTime(Date2);
int year2 = calendar.get(Calendar.YEAR);
int day2 = calendar.get(Calendar.DAY_OF_YEAR);
if ((year1 == year2) && (day1 == day2)) {
return true;
}
return false;
}
判断两个Date是否在同一天
最新推荐文章于 2024-01-29 09:26:11 发布