DateUtil { public static Instant truncatedToDay(Instant date) { notNull(date, "date can't be null"); return date.truncatedTo(ChronoUnit.DAYS); }  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 testTruncatedToDay() { doTestTruncatedToDay("2018-04-01T00:00:00Z", "2018-04-01T00:00:00Z"); doTestTruncatedToDay("2018-04-01T01:00:00Z", "2018-04-01T00:00:00Z"); doTestTruncatedToDay("2018-04-01T01:30:12Z", "2018-04-01T00:00:00Z"); doTestTruncatedToDay("2018-04-01T23:59:59Z", "2018-04-01T00:00:00Z"); doTestTruncatedToDay("2018-04-02T00:00:00Z", "2018-04-02T00:00:00Z"); doTestTruncatedToDay("2018-04-02T12:00:00Z", "2018-04-02T00:00:00Z"); }