Search in sources :

Example 21 with ZoneRules

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

the class TCKZoneRules method test_London_getOffsetInfo.

public void test_London_getOffsetInfo() {
    ZoneRules test = europeLondon();
    checkOffset(test, createLDT(2008, 1, 1), OFFSET_ZERO, 1);
    checkOffset(test, createLDT(2008, 2, 1), OFFSET_ZERO, 1);
    checkOffset(test, createLDT(2008, 3, 1), OFFSET_ZERO, 1);
    checkOffset(test, createLDT(2008, 4, 1), OFFSET_PONE, 1);
    checkOffset(test, createLDT(2008, 5, 1), OFFSET_PONE, 1);
    checkOffset(test, createLDT(2008, 6, 1), OFFSET_PONE, 1);
    checkOffset(test, createLDT(2008, 7, 1), OFFSET_PONE, 1);
    checkOffset(test, createLDT(2008, 8, 1), OFFSET_PONE, 1);
    checkOffset(test, createLDT(2008, 9, 1), OFFSET_PONE, 1);
    checkOffset(test, createLDT(2008, 10, 1), OFFSET_PONE, 1);
    checkOffset(test, createLDT(2008, 11, 1), OFFSET_ZERO, 1);
    checkOffset(test, createLDT(2008, 12, 1), OFFSET_ZERO, 1);
}
Also used : ZoneRules(java.time.zone.ZoneRules)

Example 22 with ZoneRules

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

the class TCKZoneRules method test_NewYork_getOffsetInfo_fromDST.

public void test_NewYork_getOffsetInfo_fromDST() {
    ZoneRules test = americaNewYork();
    checkOffset(test, createLDT(2008, 11, 1), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 11, 2), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 11, 3), ZoneOffset.ofHours(-5), 1);
    checkOffset(test, createLDT(2008, 11, 4), ZoneOffset.ofHours(-5), 1);
    checkOffset(test, createLDT(2008, 11, 5), ZoneOffset.ofHours(-5), 1);
    checkOffset(test, createLDT(2008, 11, 6), ZoneOffset.ofHours(-5), 1);
    checkOffset(test, createLDT(2008, 11, 7), ZoneOffset.ofHours(-5), 1);
    // cutover at 02:00 local
    checkOffset(test, LocalDateTime.of(2008, 11, 2, 0, 59, 59, 999999999), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, LocalDateTime.of(2008, 11, 2, 2, 0, 0, 0), ZoneOffset.ofHours(-5), 1);
}
Also used : ZoneRules(java.time.zone.ZoneRules)

Example 23 with ZoneRules

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

the class TCKZoneRules method test_getTransitions_immutable.

//-------------------------------------------------------------------------
@Test(expectedExceptions = UnsupportedOperationException.class)
public void test_getTransitions_immutable() {
    ZoneRules test = europeParis();
    test.getTransitions().clear();
}
Also used : ZoneRules(java.time.zone.ZoneRules) Test(org.testng.annotations.Test)

Example 24 with ZoneRules

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

the class TCKZoneRules method test_Kathmandu_nextTransition_historic.

public void test_Kathmandu_nextTransition_historic() {
    ZoneRules test = asiaKathmandu();
    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);
    }
}
Also used : ZoneRules(java.time.zone.ZoneRules) ZoneOffsetTransition(java.time.zone.ZoneOffsetTransition)

Example 25 with ZoneRules

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

the class TCKFixedZoneRules method test_getTransitionRules_immutable.

@Test(expectedExceptions = UnsupportedOperationException.class)
public void test_getTransitionRules_immutable() {
    ZoneRules test = make(OFFSET_PTWO);
    test.getTransitionRules().add(ZoneOffsetTransitionRule.of(Month.JULY, 2, null, LocalTime.of(12, 30), false, TimeDefinition.STANDARD, OFFSET_PONE, OFFSET_PTWO, OFFSET_PONE));
}
Also used : ZoneRules(java.time.zone.ZoneRules) Test(org.testng.annotations.Test)

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