use of java.time.zone.ZoneOffsetTransition in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method checkOffset.
private ZoneOffsetTransition checkOffset(ZoneRules rules, LocalDateTime dateTime, ZoneOffset offset, int type) {
List<ZoneOffset> validOffsets = rules.getValidOffsets(dateTime);
assertEquals(validOffsets.size(), type);
assertEquals(rules.getOffset(dateTime), offset);
if (type == 1) {
assertEquals(validOffsets.get(0), offset);
return null;
} else {
ZoneOffsetTransition zot = rules.getTransition(dateTime);
assertNotNull(zot);
assertEquals(zot.isOverlap(), type == 2);
assertEquals(zot.isGap(), type == 0);
assertEquals(zot.isValidOffset(offset), type == 2);
return zot;
}
}
use of java.time.zone.ZoneOffsetTransition 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.ZoneOffsetTransition in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method test_NewYork_getOffsetInfo_overlap.
public void test_NewYork_getOffsetInfo_overlap() {
ZoneRules test = americaNewYork();
final LocalDateTime dateTime = LocalDateTime.of(2008, 11, 2, 1, 0, 0, 0);
ZoneOffsetTransition trans = checkOffset(test, dateTime, ZoneOffset.ofHours(-4), OVERLAP);
assertEquals(trans.isGap(), false);
assertEquals(trans.isOverlap(), true);
assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(-4));
assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(-5));
assertEquals(trans.getInstant(), createInstant(2008, 11, 2, 2, 0, ZoneOffset.ofHours(-4)));
assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-1)), false);
assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-5)), true);
assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-4)), true);
assertEquals(trans.isValidOffset(OFFSET_PTWO), false);
assertEquals(trans.toString(), "Transition[Overlap at 2008-11-02T02:00-04:00 to -05:00]");
assertFalse(trans.equals(null));
assertFalse(trans.equals(ZoneOffset.ofHours(-4)));
assertTrue(trans.equals(trans));
final ZoneOffsetTransition otherTrans = test.getTransition(dateTime);
assertTrue(trans.equals(otherTrans));
assertEquals(trans.hashCode(), otherTrans.hashCode());
}
use of java.time.zone.ZoneOffsetTransition 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.ZoneOffsetTransition 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);
}
}
Aggregations