Search in sources :

Example 6 with ZoneRules

use of java.time.zone.ZoneRules in project jdk8u_jdk by JetBrains.

the class TCKZoneRules method test_Paris.

public void test_Paris() {
    ZoneRules test = europeParis();
    assertEquals(test.isFixedOffset(), false);
}
Also used : ZoneRules(java.time.zone.ZoneRules)

Example 7 with ZoneRules

use of java.time.zone.ZoneRules 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);
}
Also used : ZoneOffsetTransitionRule(java.time.zone.ZoneOffsetTransitionRule) ZoneRules(java.time.zone.ZoneRules) ZoneOffsetTransition(java.time.zone.ZoneOffsetTransition)

Example 8 with ZoneRules

use of java.time.zone.ZoneRules in project jdk8u_jdk by JetBrains.

the class TCKZoneRules method test_London_getOffsetInfo_fromDST.

public void test_London_getOffsetInfo_fromDST() {
    ZoneRules test = europeLondon();
    checkOffset(test, createLDT(2008, 10, 24), OFFSET_PONE, 1);
    checkOffset(test, createLDT(2008, 10, 25), OFFSET_PONE, 1);
    checkOffset(test, createLDT(2008, 10, 26), OFFSET_PONE, 1);
    checkOffset(test, createLDT(2008, 10, 27), OFFSET_ZERO, 1);
    checkOffset(test, createLDT(2008, 10, 28), OFFSET_ZERO, 1);
    checkOffset(test, createLDT(2008, 10, 29), OFFSET_ZERO, 1);
    checkOffset(test, createLDT(2008, 10, 30), OFFSET_ZERO, 1);
    checkOffset(test, createLDT(2008, 10, 31), OFFSET_ZERO, 1);
    // cutover at 01:00Z
    checkOffset(test, LocalDateTime.of(2008, 10, 26, 0, 59, 59, 999999999), OFFSET_PONE, 1);
    checkOffset(test, LocalDateTime.of(2008, 10, 26, 2, 0, 0, 0), OFFSET_ZERO, 1);
}
Also used : ZoneRules(java.time.zone.ZoneRules)

Example 9 with ZoneRules

use of java.time.zone.ZoneRules 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);
}
Also used : ZoneRules(java.time.zone.ZoneRules) ZoneOffsetTransition(java.time.zone.ZoneOffsetTransition)

Example 10 with ZoneRules

use of java.time.zone.ZoneRules in project jdk8u_jdk by JetBrains.

the class TCKZoneRules method test_Paris_getStandardOffset.

public void test_Paris_getStandardOffset() {
    ZoneRules test = europeParis();
    ZonedDateTime zdt = createZDT(1840, 1, 1, ZoneOffset.UTC);
    while (zdt.getYear() < 2010) {
        Instant instant = zdt.toInstant();
        if (zdt.toLocalDate().isBefore(LocalDate.of(1911, 3, 11))) {
            assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHoursMinutesSeconds(0, 9, 21));
        } else if (zdt.toLocalDate().isBefore(LocalDate.of(1940, 6, 14))) {
            assertEquals(test.getStandardOffset(instant), OFFSET_ZERO);
        } else if (zdt.toLocalDate().isBefore(LocalDate.of(1944, 8, 25))) {
            assertEquals(test.getStandardOffset(instant), OFFSET_PONE);
        } else if (zdt.toLocalDate().isBefore(LocalDate.of(1945, 9, 16))) {
            assertEquals(test.getStandardOffset(instant), OFFSET_ZERO);
        } else {
            assertEquals(test.getStandardOffset(instant), OFFSET_PONE);
        }
        zdt = zdt.plusMonths(6);
    }
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Instant(java.time.Instant) ZoneRules(java.time.zone.ZoneRules)

Aggregations

ZoneRules (java.time.zone.ZoneRules)68 ZoneOffsetTransition (java.time.zone.ZoneOffsetTransition)22 LocalDateTime (java.time.LocalDateTime)10 Test (org.testng.annotations.Test)10 Instant (java.time.Instant)9 ZoneOffset (java.time.ZoneOffset)9 ZonedDateTime (java.time.ZonedDateTime)9 ZoneOffsetTransitionRule (java.time.zone.ZoneOffsetTransitionRule)5 ChronoZonedDateTime (java.time.chrono.ChronoZonedDateTime)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 ObjectInputStream (java.io.ObjectInputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 OffsetDateTime (java.time.OffsetDateTime)1 TimeDefinition (java.time.zone.ZoneOffsetTransitionRule.TimeDefinition)1 ZoneRulesException (java.time.zone.ZoneRulesException)1 ArrayList (java.util.ArrayList)1 TreeMap (java.util.TreeMap)1