use of java.time.zone.ZoneRules in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method test_NewYork_preTimeZones.
public void test_NewYork_preTimeZones() {
ZoneRules test = americaNewYork();
ZonedDateTime old = createZDT(1800, 1, 1, ZoneOffset.UTC);
Instant instant = old.toInstant();
ZoneOffset offset = ZoneOffset.of("-04:56:02");
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_getOffsetInfo_gap.
public void test_London_getOffsetInfo_gap() {
ZoneRules test = europeLondon();
final LocalDateTime dateTime = LocalDateTime.of(2008, 3, 30, 1, 0, 0, 0);
ZoneOffsetTransition trans = checkOffset(test, dateTime, OFFSET_ZERO, GAP);
assertEquals(trans.isGap(), true);
assertEquals(trans.isOverlap(), false);
assertEquals(trans.getOffsetBefore(), OFFSET_ZERO);
assertEquals(trans.getOffsetAfter(), OFFSET_PONE);
assertEquals(trans.getInstant(), createInstant(2008, 3, 30, 1, 0, ZoneOffset.UTC));
assertEquals(trans.getDateTimeBefore(), LocalDateTime.of(2008, 3, 30, 1, 0));
assertEquals(trans.getDateTimeAfter(), LocalDateTime.of(2008, 3, 30, 2, 0));
assertEquals(trans.isValidOffset(OFFSET_ZERO), false);
assertEquals(trans.isValidOffset(OFFSET_PONE), false);
assertEquals(trans.isValidOffset(OFFSET_PTWO), false);
assertEquals(trans.toString(), "Transition[Gap at 2008-03-30T01:00Z to +01:00]");
assertFalse(trans.equals(null));
assertFalse(trans.equals(OFFSET_ZERO));
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_Apia_nextTransition_historic.
public void test_Apia_nextTransition_historic() {
ZoneRules test = pacificApia();
List<ZoneOffsetTransition> trans = test.getTransitions();
ZoneOffsetTransition first = trans.get(0);
assertEquals(test.nextTransition(first.getInstant().minusNanos(1)), first);
for (int i = 0; i < trans.size() - 1; i++) {
ZoneOffsetTransition cur = trans.get(i);
ZoneOffsetTransition next = trans.get(i + 1);
assertEquals(test.nextTransition(cur.getInstant()), next);
assertEquals(test.nextTransition(next.getInstant().minusNanos(1)), next);
}
}
use of java.time.zone.ZoneRules in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method test_NewYork_getOffsetInfo_toDST.
public void test_NewYork_getOffsetInfo_toDST() {
ZoneRules test = americaNewYork();
checkOffset(test, createLDT(2008, 3, 8), ZoneOffset.ofHours(-5), 1);
checkOffset(test, createLDT(2008, 3, 9), ZoneOffset.ofHours(-5), 1);
checkOffset(test, createLDT(2008, 3, 10), ZoneOffset.ofHours(-4), 1);
checkOffset(test, createLDT(2008, 3, 11), ZoneOffset.ofHours(-4), 1);
checkOffset(test, createLDT(2008, 3, 12), ZoneOffset.ofHours(-4), 1);
checkOffset(test, createLDT(2008, 3, 13), ZoneOffset.ofHours(-4), 1);
checkOffset(test, createLDT(2008, 3, 14), ZoneOffset.ofHours(-4), 1);
// cutover at 02:00 local
checkOffset(test, LocalDateTime.of(2008, 3, 9, 1, 59, 59, 999999999), ZoneOffset.ofHours(-5), 1);
checkOffset(test, LocalDateTime.of(2008, 3, 9, 3, 0, 0, 0), ZoneOffset.ofHours(-4), 1);
}
use of java.time.zone.ZoneRules in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method test_London_getOffsetInfo_overlap.
public void test_London_getOffsetInfo_overlap() {
ZoneRules test = europeLondon();
final LocalDateTime dateTime = LocalDateTime.of(2008, 10, 26, 1, 0, 0, 0);
ZoneOffsetTransition trans = checkOffset(test, dateTime, OFFSET_PONE, OVERLAP);
assertEquals(trans.isGap(), false);
assertEquals(trans.isOverlap(), true);
assertEquals(trans.getOffsetBefore(), OFFSET_PONE);
assertEquals(trans.getOffsetAfter(), OFFSET_ZERO);
assertEquals(trans.getInstant(), createInstant(2008, 10, 26, 1, 0, ZoneOffset.UTC));
assertEquals(trans.getDateTimeBefore(), LocalDateTime.of(2008, 10, 26, 2, 0));
assertEquals(trans.getDateTimeAfter(), LocalDateTime.of(2008, 10, 26, 1, 0));
assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-1)), false);
assertEquals(trans.isValidOffset(OFFSET_ZERO), true);
assertEquals(trans.isValidOffset(OFFSET_PONE), true);
assertEquals(trans.isValidOffset(OFFSET_PTWO), false);
assertEquals(trans.toString(), "Transition[Overlap at 2008-10-26T02:00+01:00 to Z]");
assertFalse(trans.equals(null));
assertFalse(trans.equals(OFFSET_PONE));
assertTrue(trans.equals(trans));
final ZoneOffsetTransition otherTrans = test.getTransition(dateTime);
assertTrue(trans.equals(otherTrans));
assertEquals(trans.hashCode(), otherTrans.hashCode());
}
Aggregations