public static boolean isSameDay(Date date1, Date date2) {
        final Calendar cal1 = Calendar.getInstance();
        final Calendar cal2 = Calendar.getInstance();
        cal1.setTime(date1);
        cal2.setTime(date2);
        return cal1.get(YEAR) == cal2.get(YEAR)
                && cal1.get(MONTH) == cal2.get(MONTH)
                && cal1.get(DAY_OF_MONTH) == cal2.get(DAY_OF_MONTH);
    }
@Test
    public void testSameDay() {
        Assert.assertTrue(isSameDay(new Date(), new Date()));
        Assert.assertFalse(isSameDay(new Date(), new Date(System.currentTimeMillis() + 24 * 60 * 60 * 1000)));
    }