public static boolean isSameMinute(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)
                && cal1.get(HOUR_OF_DAY) == cal2.get(HOUR_OF_DAY)
                && cal1.get(MINUTE) == cal2.get(MINUTE);
    }
@Test
    public void testSameMinute() {
        Assert.assertTrue(isSameMinute(new Date(), new Date()));
        Assert.assertFalse(isSameMinute(new Date(), new Date(System.currentTimeMillis() + 60 * 1000)));
    }