@Test public void testTruncatedToWeek() { doTestTruncatedToWeek("2018-04-01T00:00:00Z", "2018-04-01T00:00:00Z"); doTestTruncatedToWeek("2018-04-01T01:00:00Z", "2018-04-01T00:00:00Z"); doTestTruncatedToWeek("2018-04-01T01:30:12Z", "2018-04-01T00:00:00Z"); doTestTruncatedToWeek("2018-04-01T11:59:59Z", "2018-04-01T00:00:00Z"); doTestTruncatedToWeek("2018-04-02T00:00:00Z", "2018-04-01T00:00:00Z"); doTestTruncatedToWeek("2018-04-03T01:00:00Z", "2018-04-01T00:00:00Z"); doTestTruncatedToWeek("2018-04-07T23:59:59Z", "2018-04-01T00:00:00Z"); doTestTruncatedToWeek("2018-04-08T00:00:00Z", "2018-04-08T00:00:00Z"); doTestTruncatedToWeek("2018-04-09T00:00:00Z", "2018-04-08T00:00:00Z"); }
public static Instant truncatedToWeek(Instant date) { notNull(date, "date can't be null"); final DayOfWeek dow = ZonedDateTime.ofInstant(date, ZoneOffset.UTC).getDayOfWeek(); return truncatedToDay(date).minus(Duration.ofDays(dow.getValue() % 7)); }
DateUtil { public static Instant truncatedToWeek(Instant date) { notNull(date, "date can't be null"); final DayOfWeek dow = ZonedDateTime.ofInstant(date, ZoneOffset.UTC).getDayOfWeek(); return truncatedToDay(date).minus(Duration.ofDays(dow.getValue() % 7)); } }
DateUtil { public static Instant truncatedToWeek(Instant date) { notNull(date, "date can't be null"); final DayOfWeek dow = ZonedDateTime.ofInstant(date, ZoneOffset.UTC).getDayOfWeek(); return truncatedToDay(date).minus(Duration.ofDays(dow.getValue() % 7)); }  }
DateUtil { public static Instant truncatedToWeek(Instant date) { notNull(date, "date can't be null"); final DayOfWeek dow = ZonedDateTime.ofInstant(date, ZoneOffset.UTC).getDayOfWeek(); return truncatedToDay(date).minus(Duration.ofDays(dow.getValue() % 7)); }  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); }
DateUtil { public static Instant truncatedToWeek(Instant date) { notNull(date, "date can't be null"); final DayOfWeek dow = ZonedDateTime.ofInstant(date, ZoneOffset.UTC).getDayOfWeek(); return truncatedToDay(date).minus(Duration.ofDays(dow.getValue() % 7)); }  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; }