Search in sources :

Example 16 with ZoneRules

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

the class TCKZoneRules method test_NewYork_getOffset_fromDST.

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

Example 17 with ZoneRules

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

Example 18 with ZoneRules

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

Example 19 with ZoneRules

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

the class TCKFixedZoneRules method test_getTransitions_immutable.

@Test(expectedExceptions = UnsupportedOperationException.class)
public void test_getTransitions_immutable() {
    ZoneRules test = make(OFFSET_PTWO);
    test.getTransitions().add(ZoneOffsetTransition.of(LDT, OFFSET_PONE, OFFSET_PTWO));
}
Also used : ZoneRules(java.time.zone.ZoneRules) Test(org.testng.annotations.Test)

Example 20 with ZoneRules

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

the class TCKFixedZoneRules method test_equalsHashCode.

//-----------------------------------------------------------------------
// equals() / hashCode()
//-----------------------------------------------------------------------
@Test
public void test_equalsHashCode() {
    ZoneRules a = make(OFFSET_PONE);
    ZoneRules b = make(OFFSET_PTWO);
    assertEquals(a.equals(a), true);
    assertEquals(a.equals(b), false);
    assertEquals(b.equals(a), false);
    assertEquals(b.equals(b), true);
    assertEquals(a.equals("Rubbish"), false);
    assertEquals(a.equals(null), false);
    assertEquals(a.hashCode() == a.hashCode(), true);
    assertEquals(b.hashCode() == b.hashCode(), true);
}
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