Search in sources :

Example 61 with ZoneRules

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

the class TCKZoneRules method test_NewYork_getOffsetInfo_gap.

public void test_NewYork_getOffsetInfo_gap() {
    ZoneRules test = americaNewYork();
    final LocalDateTime dateTime = LocalDateTime.of(2008, 3, 9, 2, 0, 0, 0);
    ZoneOffsetTransition trans = checkOffset(test, dateTime, ZoneOffset.ofHours(-5), GAP);
    assertEquals(trans.isGap(), true);
    assertEquals(trans.isOverlap(), false);
    assertEquals(trans.getOffsetBefore(), ZoneOffset.ofHours(-5));
    assertEquals(trans.getOffsetAfter(), ZoneOffset.ofHours(-4));
    assertEquals(trans.getInstant(), createInstant(2008, 3, 9, 2, 0, ZoneOffset.ofHours(-5)));
    assertEquals(trans.isValidOffset(OFFSET_PTWO), false);
    assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-5)), false);
    assertEquals(trans.isValidOffset(ZoneOffset.ofHours(-4)), false);
    assertEquals(trans.toString(), "Transition[Gap at 2008-03-09T02:00-05:00 to -04:00]");
    assertFalse(trans.equals(null));
    assertFalse(trans.equals(ZoneOffset.ofHours(-5)));
    assertTrue(trans.equals(trans));
    final ZoneOffsetTransition otherTrans = test.getTransition(dateTime);
    assertTrue(trans.equals(otherTrans));
    assertEquals(trans.hashCode(), otherTrans.hashCode());
}
Also used : LocalDateTime(java.time.LocalDateTime) ZoneRules(java.time.zone.ZoneRules) ZoneOffsetTransition(java.time.zone.ZoneOffsetTransition)

Example 62 with ZoneRules

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

the class TCKZoneRules method test_NewYork_getOffsetInfo.

public void test_NewYork_getOffsetInfo() {
    ZoneRules test = americaNewYork();
    checkOffset(test, createLDT(2008, 1, 1), ZoneOffset.ofHours(-5), 1);
    checkOffset(test, createLDT(2008, 2, 1), ZoneOffset.ofHours(-5), 1);
    checkOffset(test, createLDT(2008, 3, 1), ZoneOffset.ofHours(-5), 1);
    checkOffset(test, createLDT(2008, 4, 1), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 5, 1), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 6, 1), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 7, 1), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 8, 1), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 9, 1), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 10, 1), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 11, 1), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 12, 1), ZoneOffset.ofHours(-5), 1);
    checkOffset(test, createLDT(2008, 1, 28), ZoneOffset.ofHours(-5), 1);
    checkOffset(test, createLDT(2008, 2, 28), ZoneOffset.ofHours(-5), 1);
    checkOffset(test, createLDT(2008, 3, 28), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 4, 28), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 5, 28), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 6, 28), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 7, 28), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 8, 28), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 9, 28), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 10, 28), ZoneOffset.ofHours(-4), 1);
    checkOffset(test, createLDT(2008, 11, 28), ZoneOffset.ofHours(-5), 1);
    checkOffset(test, createLDT(2008, 12, 28), ZoneOffset.ofHours(-5), 1);
}
Also used : ZoneRules(java.time.zone.ZoneRules)

Example 63 with ZoneRules

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

the class TCKZoneRules method test_NewYork.

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

Example 64 with ZoneRules

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

the class TCKZoneRules method test_London_previousTransition_historic.

//-----------------------------------------------------------------------
public void test_London_previousTransition_historic() {
    ZoneRules test = europeLondon();
    List<ZoneOffsetTransition> trans = test.getTransitions();
    ZoneOffsetTransition first = trans.get(0);
    assertEquals(test.previousTransition(first.getInstant()), null);
    assertEquals(test.previousTransition(first.getInstant().minusNanos(1)), null);
    for (int i = 0; i < trans.size() - 1; i++) {
        ZoneOffsetTransition prev = trans.get(i);
        ZoneOffsetTransition cur = trans.get(i + 1);
        assertEquals(test.previousTransition(cur.getInstant()), prev);
        assertEquals(test.previousTransition(prev.getInstant().plusSeconds(1)), prev);
        assertEquals(test.previousTransition(prev.getInstant().plusNanos(1)), prev);
    }
}
Also used : ZoneRules(java.time.zone.ZoneRules) ZoneOffsetTransition(java.time.zone.ZoneOffsetTransition)

Example 65 with ZoneRules

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

the class TCKZoneRules method test_Paris_getOffset_fromDST.

public void test_Paris_getOffset_fromDST() {
    ZoneRules test = europeParis();
    assertEquals(test.getOffset(createInstant(2008, 10, 24, ZoneOffset.UTC)), OFFSET_PTWO);
    assertEquals(test.getOffset(createInstant(2008, 10, 25, ZoneOffset.UTC)), OFFSET_PTWO);
    assertEquals(test.getOffset(createInstant(2008, 10, 26, ZoneOffset.UTC)), OFFSET_PTWO);
    assertEquals(test.getOffset(createInstant(2008, 10, 27, ZoneOffset.UTC)), OFFSET_PONE);
    assertEquals(test.getOffset(createInstant(2008, 10, 28, ZoneOffset.UTC)), OFFSET_PONE);
    assertEquals(test.getOffset(createInstant(2008, 10, 29, ZoneOffset.UTC)), OFFSET_PONE);
    assertEquals(test.getOffset(createInstant(2008, 10, 30, ZoneOffset.UTC)), OFFSET_PONE);
    assertEquals(test.getOffset(createInstant(2008, 10, 31, ZoneOffset.UTC)), OFFSET_PONE);
    // cutover at 01:00Z
    assertEquals(test.getOffset(createInstant(2008, 10, 26, 0, 59, 59, 999999999, ZoneOffset.UTC)), OFFSET_PTWO);
    assertEquals(test.getOffset(createInstant(2008, 10, 26, 1, 0, 0, 0, ZoneOffset.UTC)), OFFSET_PONE);
}
Also used : 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