use of java.time.zone.ZoneRules in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method test_Apia_jumpOverInternationalDateLine_M10_to_P14.
public void test_Apia_jumpOverInternationalDateLine_M10_to_P14() {
// transition occurred at 2011-12-30T00:00-10:00
ZoneRules test = pacificApia();
Instant instantBefore = LocalDate.of(2011, 12, 27).atStartOfDay(ZoneOffset.UTC).toInstant();
ZoneOffsetTransition trans = test.nextTransition(instantBefore);
assertEquals(trans.getDateTimeBefore(), LocalDateTime.of(2011, 12, 30, 0, 0));
assertEquals(trans.getDateTimeAfter(), LocalDateTime.of(2011, 12, 31, 0, 0));
assertEquals(trans.isGap(), true);
assertEquals(trans.isOverlap(), false);
assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-10)), false);
assertEquals(trans.isValidOffset(ZoneOffset.ofHours(+14)), false);
assertEquals(trans.getDuration(), Duration.ofHours(24));
assertEquals(trans.getInstant(), LocalDateTime.of(2011, 12, 31, 0, 0).toInstant(ZoneOffset.ofHours(+14)));
ZonedDateTime zdt = ZonedDateTime.of(2011, 12, 29, 23, 0, 0, 0, ZoneId.of("Pacific/Apia"));
assertEquals(zdt.plusHours(2).toLocalDateTime(), LocalDateTime.of(2011, 12, 31, 1, 0));
}
use of java.time.zone.ZoneRules in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method test_London_getStandardOffset.
public void test_London_getStandardOffset() {
ZoneRules test = europeLondon();
ZonedDateTime zdt = createZDT(1840, 1, 1, ZoneOffset.UTC);
while (zdt.getYear() < 2010) {
Instant instant = zdt.toInstant();
if (zdt.getYear() < 1848) {
assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHoursMinutesSeconds(0, -1, -15));
} else if (zdt.getYear() >= 1969 && zdt.getYear() < 1972) {
assertEquals(test.getStandardOffset(instant), OFFSET_PONE);
} else {
assertEquals(test.getStandardOffset(instant), OFFSET_ZERO);
}
zdt = zdt.plusMonths(6);
}
}
use of java.time.zone.ZoneRules in project jdk8u_jdk by JetBrains.
the class TestFixedZoneRules method test_data_nullInput.
//-----------------------------------------------------------------------
@Test
public void test_data_nullInput() {
ZoneRules test = make(OFFSET_PONE);
assertEquals(test.getOffset((Instant) null), OFFSET_PONE);
assertEquals(test.getOffset((LocalDateTime) null), OFFSET_PONE);
assertEquals(test.getValidOffsets(null).size(), 1);
assertEquals(test.getValidOffsets(null).get(0), OFFSET_PONE);
assertEquals(test.getTransition(null), null);
assertEquals(test.getStandardOffset(null), OFFSET_PONE);
assertEquals(test.getDaylightSavings(null), Duration.ZERO);
assertEquals(test.isDaylightSavings(null), false);
assertEquals(test.nextTransition(null), null);
assertEquals(test.previousTransition(null), null);
}
Aggregations