use of java.time.zone.ZoneOffsetTransition in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method test_London_nextTransition_lastYear.
public void test_London_nextTransition_lastYear() {
ZoneRules test = europeLondon();
List<ZoneOffsetTransitionRule> rules = test.getTransitionRules();
ZoneOffsetTransition zot = rules.get(1).createTransition(Year.MAX_VALUE);
assertEquals(test.nextTransition(zot.getInstant()), null);
}
use of java.time.zone.ZoneOffsetTransition in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method test_London_getTransitions.
public void test_London_getTransitions() {
ZoneRules test = europeLondon();
List<ZoneOffsetTransition> trans = test.getTransitions();
ZoneOffsetTransition first = trans.get(0);
assertEquals(first.getDateTimeBefore(), LocalDateTime.of(1847, 12, 1, 0, 0));
assertEquals(first.getOffsetBefore(), ZoneOffset.ofHoursMinutesSeconds(0, -1, -15));
assertEquals(first.getOffsetAfter(), OFFSET_ZERO);
ZoneOffsetTransition spring1916 = trans.get(1);
assertEquals(spring1916.getDateTimeBefore(), LocalDateTime.of(1916, 5, 21, 2, 0));
assertEquals(spring1916.getOffsetBefore(), OFFSET_ZERO);
assertEquals(spring1916.getOffsetAfter(), OFFSET_PONE);
ZoneOffsetTransition autumn1916 = trans.get(2);
assertEquals(autumn1916.getDateTimeBefore(), LocalDateTime.of(1916, 10, 1, 3, 0));
assertEquals(autumn1916.getOffsetBefore(), OFFSET_PONE);
assertEquals(autumn1916.getOffsetAfter(), OFFSET_ZERO);
ZoneOffsetTransition zot = null;
Iterator<ZoneOffsetTransition> it = trans.iterator();
while (it.hasNext()) {
zot = it.next();
if (zot.getDateTimeBefore().getYear() == 1990) {
break;
}
}
assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1990, 3, 25, 1, 0));
assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
zot = it.next();
assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1990, 10, 28, 2, 0));
assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
zot = it.next();
assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1991, 3, 31, 1, 0));
assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
zot = it.next();
assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1991, 10, 27, 2, 0));
assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
zot = it.next();
assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1992, 3, 29, 1, 0));
assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
zot = it.next();
assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1992, 10, 25, 2, 0));
assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
zot = it.next();
assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1993, 3, 28, 1, 0));
assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
zot = it.next();
assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1993, 10, 24, 2, 0));
assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
zot = it.next();
assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1994, 3, 27, 1, 0));
assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
zot = it.next();
assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1994, 10, 23, 2, 0));
assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
zot = it.next();
assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1995, 3, 26, 1, 0));
assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
zot = it.next();
assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1995, 10, 22, 2, 0));
assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
zot = it.next();
assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1996, 3, 31, 1, 0));
assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
zot = it.next();
assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1996, 10, 27, 2, 0));
assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
zot = it.next();
assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1997, 3, 30, 1, 0));
assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
zot = it.next();
assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1997, 10, 26, 2, 0));
assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
assertEquals(it.hasNext(), false);
}
use of java.time.zone.ZoneOffsetTransition in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method test_Kathmandu_nextTransition_noRules.
public void test_Kathmandu_nextTransition_noRules() {
ZoneRules test = asiaKathmandu();
List<ZoneOffsetTransition> trans = test.getTransitions();
ZoneOffsetTransition last = trans.get(trans.size() - 1);
assertEquals(test.nextTransition(last.getInstant()), null);
}
use of java.time.zone.ZoneOffsetTransition in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method test_London_nextTransition_historic.
//-----------------------------------------------------------------------
public void test_London_nextTransition_historic() {
ZoneRules test = europeLondon();
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.ZoneOffsetTransition in project jdk8u_jdk by JetBrains.
the class TestZoneId method test_London_getOffsetInfo_overlap.
public void test_London_getOffsetInfo_overlap() {
ZoneId test = ZoneId.of("Europe/London");
final LocalDateTime dateTime = LocalDateTime.of(2008, 10, 26, 1, 0, 0, 0);
ZoneOffsetTransition trans = checkOffset(test.getRules(), dateTime, ZoneOffset.ofHours(1), OVERLAP);
assertEquals(trans.isGap(), false);
assertEquals(trans.isOverlap(), true);
assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(1));
assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(0));
assertEquals(trans.getInstant(), dateTime.toInstant(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(ZoneOffset.ofHours(0)), true);
assertEquals(trans.isValidOffset(ZoneOffset.ofHours(1)), true);
assertEquals(trans.isValidOffset(ZoneOffset.ofHours(2)), false);
assertEquals(trans.toString(), "Transition[Overlap at 2008-10-26T02:00+01:00 to Z]");
assertFalse(trans.equals(null));
assertFalse(trans.equals(ZoneOffset.ofHours(1)));
assertTrue(trans.equals(trans));
final ZoneOffsetTransition otherTrans = test.getRules().getTransition(dateTime);
assertTrue(trans.equals(otherTrans));
assertEquals(trans.hashCode(), otherTrans.hashCode());
}
Aggregations