Search in sources :

Example 1 with Clock

use of org.threeten.bp.Clock in project SeriesGuide by UweTrottmann.

the class TimeToolsTest method test_getShowReleaseDateTime_dstGap.

@Test
public void test_getShowReleaseDateTime_dstGap() {
    // using begin of daylight saving time in Europe/Berlin on 2017-03-26
    // clock moves forward at 2:00 by 1 hour
    ZoneId zoneIdBerlin = ZoneId.of(EUROPE_BERLIN);
    Instant instantDayOfDstStart = ZonedDateTime.of(LocalDateTime.of(2017, 3, 26, 1, 0), zoneIdBerlin).toInstant();
    Clock fixedClock = Clock.fixed(instantDayOfDstStart, zoneIdBerlin);
    // put show release exactly inside daylight saving gap (02:00-03:00)
    ZonedDateTime dateTime = TimeTools.getShowReleaseDateTime(LocalTime.of(2, 30), DayOfWeek.SUNDAY.getValue(), zoneIdBerlin, GERMANY, "Some Network", fixedClock);
    // time should be "fixed" by moving an hour forward
    assertThat(dateTime.toLocalTime()).isEqualTo(LocalTime.of(3, 30));
}
Also used : ZoneId(org.threeten.bp.ZoneId) ZonedDateTime(org.threeten.bp.ZonedDateTime) Instant(org.threeten.bp.Instant) Clock(org.threeten.bp.Clock) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 Clock (org.threeten.bp.Clock)1 Instant (org.threeten.bp.Instant)1 ZoneId (org.threeten.bp.ZoneId)1 ZonedDateTime (org.threeten.bp.ZonedDateTime)1