1public static boolean isSameDay(Date date1, Date date2) {
2 SimpleDateFormat fmt = new SimpleDateFormat("yyyyMMdd");
3 return fmt.format(date1).equals(fmt.format(date2));
4}
1public static boolean isSameDay(Date date1, Date date2) {
2 Calendar calendar1 = Calendar.getInstance();
3 calendar1.setTime(date1);
4 Calendar calendar2 = Calendar.getInstance();
5 calendar2.setTime(date2);
6 return calendar1.get(Calendar.YEAR) == calendar2.get(Calendar.YEAR)
7 && calendar1.get(Calendar.MONTH) == calendar2.get(Calendar.MONTH)
8 && calendar1.get(Calendar.DAY_OF_MONTH) == calendar2.get(Calendar.DAY_OF_MONTH);
9}