Search in sources :

Example 1 with ZoneOffsetTransitionRule

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

the class TCKZoneOffsetTransitionRuleSerialization method test_serialization_unusualOffsets.

//-----------------------------------------------------------------------
// Test serialization
//-----------------------------------------------------------------------
@Test
public void test_serialization_unusualOffsets() throws Exception {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD, ZoneOffset.ofHoursMinutesSeconds(-12, -20, -50), ZoneOffset.ofHoursMinutesSeconds(-4, -10, -34), ZoneOffset.ofHours(-18));
    assertSerializable(test);
}
Also used : ZoneOffsetTransitionRule(java.time.zone.ZoneOffsetTransitionRule) Test(org.testng.annotations.Test) AbstractTCKTest(tck.java.time.AbstractTCKTest)

Example 2 with ZoneOffsetTransitionRule

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

the class TCKZoneOffsetTransitionRuleSerialization method test_serialization_floatingWeek.

@Test
public void test_serialization_floatingWeek() throws Exception {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertSerializable(test);
}
Also used : ZoneOffsetTransitionRule(java.time.zone.ZoneOffsetTransitionRule) Test(org.testng.annotations.Test) AbstractTCKTest(tck.java.time.AbstractTCKTest)

Example 3 with ZoneOffsetTransitionRule

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

the class TCKZoneOffsetTransitionRuleSerialization method test_serialization_endOfDay.

@Test
public void test_serialization_endOfDay() throws Exception {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(Month.MARCH, 20, DayOfWeek.FRIDAY, LocalTime.MIDNIGHT, true, TimeDefinition.UTC, OFFSET_0200, OFFSET_0200, OFFSET_0300);
    assertSerializable(test);
}
Also used : ZoneOffsetTransitionRule(java.time.zone.ZoneOffsetTransitionRule) Test(org.testng.annotations.Test) AbstractTCKTest(tck.java.time.AbstractTCKTest)

Example 4 with ZoneOffsetTransitionRule

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

the class TCKZoneRules method test_London_previousTransition_rulesBased.

public void test_London_previousTransition_rulesBased() {
    ZoneRules test = europeLondon();
    List<ZoneOffsetTransitionRule> rules = test.getTransitionRules();
    List<ZoneOffsetTransition> trans = test.getTransitions();
    ZoneOffsetTransition last = trans.get(trans.size() - 1);
    assertEquals(test.previousTransition(last.getInstant().plusSeconds(1)), last);
    assertEquals(test.previousTransition(last.getInstant().plusNanos(1)), last);
    // Jan 1st of year between transitions and rules
    ZonedDateTime odt = ZonedDateTime.ofInstant(last.getInstant(), last.getOffsetAfter());
    odt = odt.withDayOfYear(1).plusYears(1).with(LocalTime.MIDNIGHT);
    assertEquals(test.previousTransition(odt.toInstant()), last);
    // later years
    for (int year = 1998; year < 2010; year++) {
        ZoneOffsetTransition a = rules.get(0).createTransition(year);
        ZoneOffsetTransition b = rules.get(1).createTransition(year);
        ZoneOffsetTransition c = rules.get(0).createTransition(year + 1);
        assertEquals(test.previousTransition(c.getInstant()), b);
        assertEquals(test.previousTransition(b.getInstant().plusSeconds(1)), b);
        assertEquals(test.previousTransition(b.getInstant().plusNanos(1)), b);
        assertEquals(test.previousTransition(b.getInstant()), a);
        assertEquals(test.previousTransition(a.getInstant().plusSeconds(1)), a);
        assertEquals(test.previousTransition(a.getInstant().plusNanos(1)), a);
    }
}
Also used : ZoneOffsetTransitionRule(java.time.zone.ZoneOffsetTransitionRule) ZonedDateTime(java.time.ZonedDateTime) ZoneRules(java.time.zone.ZoneRules) ZoneOffsetTransition(java.time.zone.ZoneOffsetTransition)

Example 5 with ZoneOffsetTransitionRule

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

the class TCKZoneRules method test_London_nextTransition_rulesBased.

public void test_London_nextTransition_rulesBased() {
    ZoneRules test = europeLondon();
    List<ZoneOffsetTransitionRule> rules = test.getTransitionRules();
    List<ZoneOffsetTransition> trans = test.getTransitions();
    ZoneOffsetTransition last = trans.get(trans.size() - 1);
    assertEquals(test.nextTransition(last.getInstant()), rules.get(0).createTransition(1998));
    for (int year = 1998; year < 2010; year++) {
        ZoneOffsetTransition a = rules.get(0).createTransition(year);
        ZoneOffsetTransition b = rules.get(1).createTransition(year);
        ZoneOffsetTransition c = rules.get(0).createTransition(year + 1);
        assertEquals(test.nextTransition(a.getInstant()), b);
        assertEquals(test.nextTransition(b.getInstant().minusNanos(1)), b);
        assertEquals(test.nextTransition(b.getInstant()), c);
        assertEquals(test.nextTransition(c.getInstant().minusNanos(1)), c);
    }
}
Also used : ZoneOffsetTransitionRule(java.time.zone.ZoneOffsetTransitionRule) ZoneRules(java.time.zone.ZoneRules) ZoneOffsetTransition(java.time.zone.ZoneOffsetTransition)

Aggregations

ZoneOffsetTransitionRule (java.time.zone.ZoneOffsetTransitionRule)84 AbstractTCKTest (tck.java.time.AbstractTCKTest)72 Test (org.junit.Test)36 Test (org.testng.annotations.Test)36 ZoneOffsetTransition (java.time.zone.ZoneOffsetTransition)22 ZoneRules (java.time.zone.ZoneRules)10 Instant (java.time.Instant)2 LocalDateTime (java.time.LocalDateTime)2 OffsetDateTime (java.time.OffsetDateTime)2 ZoneId (java.time.ZoneId)2 ZoneOffset (java.time.ZoneOffset)2 ZonedDateTime (java.time.ZonedDateTime)2 TimeDefinition (java.time.zone.ZoneOffsetTransitionRule.TimeDefinition)2 ArrayList (java.util.ArrayList)2 RuntimeMXBean (java.lang.management.RuntimeMXBean)1 ThreadMXBean (java.lang.management.ThreadMXBean)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1