DateUtils { public static boolean compareDateEndWithMinute(Date d1, Date d2) { SimpleDateFormat dateFormatEndWithMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm"); String s1 = dateFormatEndWithMinute.format(d1); String s2 = dateFormatEndWithMinute.format(d2); return (s1.equals(s2)); }  static long getCollectTimeInLong(Date date); static Date convertToServerDate(String userTimeZone, Date userDate); static Date convertToUserDate(String userTimeZone, Date serverDate); static String dateToString(Date date); static Map<String, String> getFilteredTimeZoneMap(); static Date toSimpleDate(String strDate); static Date toDate(String strDate); static Date addDay(Date date, int days); static String ms2Time(long ms); static long timeToMs(int day, int hour, int min, int sec); static boolean compareDateEndWithMinute(Date d1, Date d2);  }
@SuppressWarnings("deprecation") @Test public void testCompareDateEndWithMinute() { Date date1 = new Date(); date1.setSeconds(0); Date date2 = new Date(date1.getTime()); date2.setSeconds(10); assertTrue(DateUtils.compareDateEndWithMinute(date1, date2)); assertTrue(DateUtils.compareDateEndWithMinute(date1, date1)); date2 = new Date(date1.getTime()); if (date1.getMinutes() > 1) { date2.setMinutes(date1.getMinutes() - 1); } else { date2.setMinutes(date1.getMinutes() + 1); } assertTrue(!DateUtils.compareDateEndWithMinute(date1, date2)); }