DateUtil { public static Instant truncatedToSeconds(Instant date) { notNull(date, "date can't be null"); return date.truncatedTo(ChronoUnit.SECONDS); }  static Instant truncatedToDay(Instant date); static Instant truncatedToWeek(Instant date); static Instant snapToSeconds(Instant date, int seconds); static Instant truncatedToSeconds(Instant date); static String epochSecondToString(long metricTimestamp); static Instant epochSecondToInstant(long metricTimestamp); static boolean isBetweenHours(int hour, int startHour, int endHour); static boolean crossesMidnight(int startHour, int endHour); static ZonedDateTime instantToUTCDateTime(Instant epochSecond); static final int MIDNIGHT_HOUR; }
@Test public void testTruncatedToSeconds() { doTestTruncatedToSeconds("2018-04-01T09:24:54.63Z", "2018-04-01T09:24:54.00Z"); doTestTruncatedToSeconds("2018-04-01T09:24:54.01Z", "2018-04-01T09:24:54.00Z"); doTestTruncatedToSeconds("2018-04-01T09:24:53.41Z", "2018-04-01T09:24:53.00Z"); }