@Test public void testToSeconds() throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS"); Date d1 = sdf.parse("2018-12-12 23:59:59:888"); Date d2 = sdf.parse("2018-12-13 00:00:00:888"); Date d3 = sdf.parse("2018-12-13 00:00:01:888"); assertTrue(DateUtils.toSeconds(d1) + 1 == DateUtils.toSeconds(d2)); assertTrue(DateUtils.toSeconds(d2) + 1 == DateUtils.toSeconds(d3)); }
public static long toSeconds(Date date) { return toSeconds(date.getTime()); }
DateUtils { public static long toSeconds(Date date) { return toSeconds(date.getTime()); } }
DateUtils { public static long toSeconds(Date date) { return toSeconds(date.getTime()); }  }
DateUtils { public static long toSeconds(Date date) { return toSeconds(date.getTime()); }  static boolean isSameDay(final Date date1, final Date date2); static boolean isSameDay(final Calendar cal1, final Calendar cal2); static boolean isSameWeek(final Date date1, final Date date2); static boolean isSameWeek(Calendar cal1, Calendar cal2); static boolean isSameMonth(final Date date1, final Date date2); static boolean isSameMonth(Calendar cal1, Calendar cal2); static Date addYears(final Date date, final int amount); static Date addMonths(final Date date, final int amount); static Date addWeeks(final Date date, final int amount); static Date addDays(final Date date, final int amount); static Date addHours(final Date date, final int amount); static Date addMinutes(final Date date, final int amount); static Date addSeconds(final Date date, final int amount); static Date addMilliseconds(final Date date, final int amount); static long toSeconds(Date date); static long toSeconds(long milliseconds); static long toSecondsByStartOfDay(LocalDate localDate); static long toDays(Date date); static long toDays(long milliseconds); static long diffSeconds(Date date1, Date date2); static long diffDays(Date date1, Date date2); static String formatTime(long seconds); }
DateUtils { public static long toSeconds(Date date) { return toSeconds(date.getTime()); }  static boolean isSameDay(final Date date1, final Date date2); static boolean isSameDay(final Calendar cal1, final Calendar cal2); static boolean isSameWeek(final Date date1, final Date date2); static boolean isSameWeek(Calendar cal1, Calendar cal2); static boolean isSameMonth(final Date date1, final Date date2); static boolean isSameMonth(Calendar cal1, Calendar cal2); static Date addYears(final Date date, final int amount); static Date addMonths(final Date date, final int amount); static Date addWeeks(final Date date, final int amount); static Date addDays(final Date date, final int amount); static Date addHours(final Date date, final int amount); static Date addMinutes(final Date date, final int amount); static Date addSeconds(final Date date, final int amount); static Date addMilliseconds(final Date date, final int amount); static long toSeconds(Date date); static long toSeconds(long milliseconds); static long toSecondsByStartOfDay(LocalDate localDate); static long toDays(Date date); static long toDays(long milliseconds); static long diffSeconds(Date date1, Date date2); static long diffDays(Date date1, Date date2); static String formatTime(long seconds); static final int MILLISECOND_PER_SECOND; static final int SECOND_PER_MINUTE; static final int MINUTE_PER_HOUR; static final int HOUR_PER_DAY; }