@Test public void nextDayOfMondayToSaturdayStartsAt00OClockLondonTime() { final D1 cut = new D1(); for (int day = 10; day <= 15; day++) { assertThat(cut.instantOfNextFrame( LocalDate.of(2010, Month.MAY, day).atTime(20, 4, 52, 5721).toInstant(ZoneOffset.ofHours(2)))) .isEqualTo(LocalDate.of(2010, Month.MAY, day + 1).atTime(0, 0, 0, 0) .toInstant(ZoneOffset.ofHours(1))); } for (int day = 16; day <= 21; day++) { assertThat(cut.instantOfNextFrame( LocalDate.of(1996, Month.DECEMBER, day).atTime(20, 4, 52, 5721).toInstant(ZoneOffset.ofHours(1)))) .isEqualTo(LocalDate.of(1996, Month.DECEMBER, day + 1).atTime(0, 0, 0, 0) .toInstant(ZoneOffset.ofHours(0))); } }
@Override public Instant instantOfNextFrame(final Instant instant) { final ZonedDateTime britishTime = instant.atZone(BRITISH_TIME_ZONE); final DayOfWeek britishDay = britishTime.getDayOfWeek(); if (britishDay != SUNDAY) { return removeMinutesAndLess(britishTime).withHour(0).plus(1, DAYS).toInstant(); } final ZonedDateTime britishTimeCorrectTimeValues = removeMinutesAndLess(britishTime).withHour(22); if (britishTime.getDayOfWeek() == SUNDAY) { if (britishTime.isBefore(britishTimeCorrectTimeValues)) { return britishTimeCorrectTimeValues.toInstant(); } return removeMinutesAndLess(britishTime).withHour(0).plus(2, DAYS).toInstant(); } return britishTimeCorrectTimeValues.with(TemporalAdjusters.next(SUNDAY)).toInstant(); }
D1 implements TimeFrame { @Override public Instant instantOfNextFrame(final Instant instant) { final ZonedDateTime britishTime = instant.atZone(BRITISH_TIME_ZONE); final DayOfWeek britishDay = britishTime.getDayOfWeek(); if (britishDay != SUNDAY) { return removeMinutesAndLess(britishTime).withHour(0).plus(1, DAYS).toInstant(); } final ZonedDateTime britishTimeCorrectTimeValues = removeMinutesAndLess(britishTime).withHour(22); if (britishTime.getDayOfWeek() == SUNDAY) { if (britishTime.isBefore(britishTimeCorrectTimeValues)) { return britishTimeCorrectTimeValues.toInstant(); } return removeMinutesAndLess(britishTime).withHour(0).plus(2, DAYS).toInstant(); } return britishTimeCorrectTimeValues.with(TemporalAdjusters.next(SUNDAY)).toInstant(); } }
D1 implements TimeFrame { @Override public Instant instantOfNextFrame(final Instant instant) { final ZonedDateTime britishTime = instant.atZone(BRITISH_TIME_ZONE); final DayOfWeek britishDay = britishTime.getDayOfWeek(); if (britishDay != SUNDAY) { return removeMinutesAndLess(britishTime).withHour(0).plus(1, DAYS).toInstant(); } final ZonedDateTime britishTimeCorrectTimeValues = removeMinutesAndLess(britishTime).withHour(22); if (britishTime.getDayOfWeek() == SUNDAY) { if (britishTime.isBefore(britishTimeCorrectTimeValues)) { return britishTimeCorrectTimeValues.toInstant(); } return removeMinutesAndLess(britishTime).withHour(0).plus(2, DAYS).toInstant(); } return britishTimeCorrectTimeValues.with(TemporalAdjusters.next(SUNDAY)).toInstant(); }  }
D1 implements TimeFrame { @Override public Instant instantOfNextFrame(final Instant instant) { final ZonedDateTime britishTime = instant.atZone(BRITISH_TIME_ZONE); final DayOfWeek britishDay = britishTime.getDayOfWeek(); if (britishDay != SUNDAY) { return removeMinutesAndLess(britishTime).withHour(0).plus(1, DAYS).toInstant(); } final ZonedDateTime britishTimeCorrectTimeValues = removeMinutesAndLess(britishTime).withHour(22); if (britishTime.getDayOfWeek() == SUNDAY) { if (britishTime.isBefore(britishTimeCorrectTimeValues)) { return britishTimeCorrectTimeValues.toInstant(); } return removeMinutesAndLess(britishTime).withHour(0).plus(2, DAYS).toInstant(); } return britishTimeCorrectTimeValues.with(TemporalAdjusters.next(SUNDAY)).toInstant(); }  @Override Instant instantOfNextFrame(final Instant instant); @Override boolean areInSameTimeFrame(final Instant instant1, final Instant instant2); }
D1 implements TimeFrame { @Override public Instant instantOfNextFrame(final Instant instant) { final ZonedDateTime britishTime = instant.atZone(BRITISH_TIME_ZONE); final DayOfWeek britishDay = britishTime.getDayOfWeek(); if (britishDay != SUNDAY) { return removeMinutesAndLess(britishTime).withHour(0).plus(1, DAYS).toInstant(); } final ZonedDateTime britishTimeCorrectTimeValues = removeMinutesAndLess(britishTime).withHour(22); if (britishTime.getDayOfWeek() == SUNDAY) { if (britishTime.isBefore(britishTimeCorrectTimeValues)) { return britishTimeCorrectTimeValues.toInstant(); } return removeMinutesAndLess(britishTime).withHour(0).plus(2, DAYS).toInstant(); } return britishTimeCorrectTimeValues.with(TemporalAdjusters.next(SUNDAY)).toInstant(); }  @Override Instant instantOfNextFrame(final Instant instant); @Override boolean areInSameTimeFrame(final Instant instant1, final Instant instant2);  }