use of java.time.zone.ZoneRules in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method test_Apia_jumpForwardOverInternationalDateLine_P12_to_M12.
public void test_Apia_jumpForwardOverInternationalDateLine_P12_to_M12() {
// transition occurred at 1879-07-04T00:00+12:33:04
ZoneRules test = pacificApia();
Instant instantBefore = LocalDate.of(1879, 7, 2).atStartOfDay(ZoneOffset.UTC).toInstant();
ZoneOffsetTransition trans = test.nextTransition(instantBefore);
assertEquals(trans.getDateTimeBefore(), LocalDateTime.of(1879, 7, 5, 0, 0));
assertEquals(trans.getDateTimeAfter(), LocalDateTime.of(1879, 7, 4, 0, 0));
assertEquals(trans.isGap(), false);
assertEquals(trans.isOverlap(), true);
assertEquals(trans.isValidOffset(ZoneOffset.ofHoursMinutesSeconds(+12, 33, 4)), true);
assertEquals(trans.isValidOffset(ZoneOffset.ofHoursMinutesSeconds(-11, -26, -56)), true);
assertEquals(trans.getDuration(), Duration.ofHours(-24));
assertEquals(trans.getInstant(), LocalDateTime.of(1879, 7, 4, 0, 0).toInstant(ZoneOffset.ofHoursMinutesSeconds(-11, -26, -56)));
ZonedDateTime zdt = ZonedDateTime.of(1879, 7, 4, 23, 0, 0, 0, ZoneId.of("Pacific/Apia"));
assertEquals(zdt.plusHours(2).toLocalDateTime(), LocalDateTime.of(1879, 7, 4, 1, 0, 0));
}
use of java.time.zone.ZoneRules in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method test_London_getOffset_toDST.
public void test_London_getOffset_toDST() {
ZoneRules test = europeLondon();
assertEquals(test.getOffset(createInstant(2008, 3, 24, ZoneOffset.UTC)), OFFSET_ZERO);
assertEquals(test.getOffset(createInstant(2008, 3, 25, ZoneOffset.UTC)), OFFSET_ZERO);
assertEquals(test.getOffset(createInstant(2008, 3, 26, ZoneOffset.UTC)), OFFSET_ZERO);
assertEquals(test.getOffset(createInstant(2008, 3, 27, ZoneOffset.UTC)), OFFSET_ZERO);
assertEquals(test.getOffset(createInstant(2008, 3, 28, ZoneOffset.UTC)), OFFSET_ZERO);
assertEquals(test.getOffset(createInstant(2008, 3, 29, ZoneOffset.UTC)), OFFSET_ZERO);
assertEquals(test.getOffset(createInstant(2008, 3, 30, ZoneOffset.UTC)), OFFSET_ZERO);
assertEquals(test.getOffset(createInstant(2008, 3, 31, ZoneOffset.UTC)), OFFSET_PONE);
// cutover at 01:00Z
assertEquals(test.getOffset(createInstant(2008, 3, 30, 0, 59, 59, 999999999, ZoneOffset.UTC)), OFFSET_ZERO);
assertEquals(test.getOffset(createInstant(2008, 3, 30, 1, 0, 0, 0, ZoneOffset.UTC)), OFFSET_PONE);
}
use of java.time.zone.ZoneRules in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method test_Paris_getOffsetInfo_overlap.
public void test_Paris_getOffsetInfo_overlap() {
ZoneRules test = europeParis();
final LocalDateTime dateTime = LocalDateTime.of(2008, 10, 26, 2, 0, 0, 0);
ZoneOffsetTransition trans = checkOffset(test, dateTime, OFFSET_PTWO, OVERLAP);
assertEquals(trans.isGap(), false);
assertEquals(trans.isOverlap(), true);
assertEquals(trans.getOffsetBefore(), OFFSET_PTWO);
assertEquals(trans.getOffsetAfter(), OFFSET_PONE);
assertEquals(trans.getInstant(), createInstant(2008, 10, 26, 1, 0, ZoneOffset.UTC));
assertEquals(trans.isValidOffset(OFFSET_ZERO), false);
assertEquals(trans.isValidOffset(OFFSET_PONE), true);
assertEquals(trans.isValidOffset(OFFSET_PTWO), true);
assertEquals(trans.isValidOffset(ZoneOffset.ofHours(3)), false);
assertEquals(trans.toString(), "Transition[Overlap at 2008-10-26T03:00+02:00 to +01:00]");
assertFalse(trans.equals(null));
assertFalse(trans.equals(OFFSET_PTWO));
assertTrue(trans.equals(trans));
final ZoneOffsetTransition otherTrans = test.getTransition(dateTime);
assertTrue(trans.equals(otherTrans));
assertEquals(trans.hashCode(), otherTrans.hashCode());
}
use of java.time.zone.ZoneRules in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method test_Paris_preTimeZones.
public void test_Paris_preTimeZones() {
ZoneRules test = europeParis();
ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC);
Instant instant = old.toInstant();
ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(0, 9, 21);
assertEquals(test.getOffset(instant), offset);
checkOffset(test, old.toLocalDateTime(), offset, 1);
assertEquals(test.getStandardOffset(instant), offset);
assertEquals(test.getDaylightSavings(instant), Duration.ZERO);
assertEquals(test.isDaylightSavings(instant), false);
}
use of java.time.zone.ZoneRules in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method test_London_getOffset_fromDST.
public void test_London_getOffset_fromDST() {
ZoneRules test = europeLondon();
assertEquals(test.getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC)), OFFSET_PONE);
assertEquals(test.getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC)), OFFSET_PONE);
assertEquals(test.getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC)), OFFSET_PONE);
assertEquals(test.getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC)), OFFSET_ZERO);
assertEquals(test.getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC)), OFFSET_ZERO);
assertEquals(test.getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC)), OFFSET_ZERO);
assertEquals(test.getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC)), OFFSET_ZERO);
assertEquals(test.getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC)), OFFSET_ZERO);
// cutover at 01:00Z
assertEquals(test.getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC)), OFFSET_PONE);
assertEquals(test.getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC)), OFFSET_ZERO);
}
Aggregations