Search in sources :

Example 36 with ZoneOffsetTransition

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

the class TCKZoneOffsetTransition method test_compareTo_sameInstant.

@Test
public void test_compareTo_sameInstant() {
    ZoneOffsetTransition a = ZoneOffsetTransition.of(LocalDateTime.ofEpochSecond(23875287L, 0, OFFSET_0200), OFFSET_0200, OFFSET_0300);
    ZoneOffsetTransition b = ZoneOffsetTransition.of(LocalDateTime.ofEpochSecond(23875287L, 0, OFFSET_0300), OFFSET_0300, OFFSET_0200);
    ZoneOffsetTransition c = ZoneOffsetTransition.of(LocalDateTime.ofEpochSecond(23875287L, 0, OFFSET_0100), OFFSET_0100, OFFSET_0400);
    assertEquals(a.compareTo(a) == 0, true);
    assertEquals(a.compareTo(b) == 0, true);
    assertEquals(a.compareTo(c) == 0, true);
    assertEquals(b.compareTo(a) == 0, true);
    assertEquals(b.compareTo(b) == 0, true);
    assertEquals(b.compareTo(c) == 0, true);
    assertEquals(c.compareTo(a) == 0, true);
    assertEquals(c.compareTo(b) == 0, true);
    assertEquals(c.compareTo(c) == 0, true);
}
Also used : ZoneOffsetTransition(java.time.zone.ZoneOffsetTransition) Test(org.testng.annotations.Test) AbstractTCKTest(tck.java.time.AbstractTCKTest)

Example 37 with ZoneOffsetTransition

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

the class TCKZoneOffsetTransition method test_isValidOffset_overlap.

@Test
public void test_isValidOffset_overlap() {
    LocalDateTime ldt = LocalDateTime.of(2010, 10, 31, 1, 0);
    ZoneOffsetTransition test = ZoneOffsetTransition.of(ldt, OFFSET_0300, OFFSET_0200);
    assertEquals(test.isValidOffset(OFFSET_0100), false);
    assertEquals(test.isValidOffset(OFFSET_0200), true);
    assertEquals(test.isValidOffset(OFFSET_0230), false);
    assertEquals(test.isValidOffset(OFFSET_0300), true);
    assertEquals(test.isValidOffset(OFFSET_0400), false);
}
Also used : LocalDateTime(java.time.LocalDateTime) ZoneOffsetTransition(java.time.zone.ZoneOffsetTransition) Test(org.testng.annotations.Test) AbstractTCKTest(tck.java.time.AbstractTCKTest)

Example 38 with ZoneOffsetTransition

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

the class TCKZoneOffsetTransition method test_getters_gap.

//-----------------------------------------------------------------------
// getters
//-----------------------------------------------------------------------
@Test
public void test_getters_gap() throws Exception {
    LocalDateTime before = LocalDateTime.of(2010, 3, 31, 1, 0);
    LocalDateTime after = LocalDateTime.of(2010, 3, 31, 2, 0);
    ZoneOffsetTransition test = ZoneOffsetTransition.of(before, OFFSET_0200, OFFSET_0300);
    assertEquals(test.isGap(), true);
    assertEquals(test.isOverlap(), false);
    assertEquals(test.getDateTimeBefore(), before);
    assertEquals(test.getDateTimeAfter(), after);
    assertEquals(test.getInstant(), before.toInstant(OFFSET_0200));
    assertEquals(test.getOffsetBefore(), OFFSET_0200);
    assertEquals(test.getOffsetAfter(), OFFSET_0300);
    assertEquals(test.getDuration(), Duration.of(1, HOURS));
}
Also used : LocalDateTime(java.time.LocalDateTime) ZoneOffsetTransition(java.time.zone.ZoneOffsetTransition) Test(org.testng.annotations.Test) AbstractTCKTest(tck.java.time.AbstractTCKTest)

Example 39 with ZoneOffsetTransition

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

the class TCKZoneOffsetTransitionRule method test_createTransition_floatingWeekBackwards_seventhLast.

@Test
public void test_createTransition_floatingWeekBackwards_seventhLast() {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(Month.MARCH, -7, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300);
    ZoneOffsetTransition trans = ZoneOffsetTransition.of(LocalDateTime.of(2000, Month.MARCH, 19, 1, 0), OFFSET_0200, OFFSET_0300);
    assertEquals(test.createTransition(2000), trans);
}
Also used : ZoneOffsetTransitionRule(java.time.zone.ZoneOffsetTransitionRule) ZoneOffsetTransition(java.time.zone.ZoneOffsetTransition) Test(org.testng.annotations.Test) AbstractTCKTest(tck.java.time.AbstractTCKTest)

Example 40 with ZoneOffsetTransition

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

the class TCKZoneOffsetTransitionRule method test_createTransition_floatingWeekBackwards_last.

@Test
public void test_createTransition_floatingWeekBackwards_last() {
    ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300);
    ZoneOffsetTransition trans = ZoneOffsetTransition.of(LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300);
    assertEquals(test.createTransition(2000), trans);
}
Also used : ZoneOffsetTransitionRule(java.time.zone.ZoneOffsetTransitionRule) ZoneOffsetTransition(java.time.zone.ZoneOffsetTransition) Test(org.testng.annotations.Test) AbstractTCKTest(tck.java.time.AbstractTCKTest)

Aggregations

ZoneOffsetTransition (java.time.zone.ZoneOffsetTransition)52 LocalDateTime (java.time.LocalDateTime)26 ZoneRules (java.time.zone.ZoneRules)22 Test (org.testng.annotations.Test)20 AbstractTCKTest (tck.java.time.AbstractTCKTest)20 ZoneOffsetTransitionRule (java.time.zone.ZoneOffsetTransitionRule)12 ZoneId (java.time.ZoneId)8 Instant (java.time.Instant)4 ZoneOffset (java.time.ZoneOffset)4 ZonedDateTime (java.time.ZonedDateTime)3 ChronoZonedDateTime (java.time.chrono.ChronoZonedDateTime)2 RuntimeMXBean (java.lang.management.RuntimeMXBean)1 ThreadMXBean (java.lang.management.ThreadMXBean)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 OffsetDateTime (java.time.OffsetDateTime)1 TimeDefinition (java.time.zone.ZoneOffsetTransitionRule.TimeDefinition)1 ArrayList (java.util.ArrayList)1