Search in sources :

Example 6 with ZoneOffset

use of java.time.ZoneOffset in project jdk8u_jdk by JetBrains.

the class TCKZoneOffset method test_getRules.

//-----------------------------------------------------------------------
// getRules()
//-----------------------------------------------------------------------
@Test
public void test_getRules() {
    ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3);
    assertEquals(offset.getRules().isFixedOffset(), true);
    assertEquals(offset.getRules().getOffset((Instant) null), offset);
    assertEquals(offset.getRules().getDaylightSavings((Instant) null), Duration.ZERO);
    assertEquals(offset.getRules().getStandardOffset((Instant) null), offset);
    assertEquals(offset.getRules().nextTransition((Instant) null), null);
    assertEquals(offset.getRules().previousTransition((Instant) null), null);
    assertEquals(offset.getRules().isValidOffset((LocalDateTime) null, offset), true);
    assertEquals(offset.getRules().isValidOffset((LocalDateTime) null, ZoneOffset.UTC), false);
    assertEquals(offset.getRules().isValidOffset((LocalDateTime) null, null), false);
    assertEquals(offset.getRules().getOffset((LocalDateTime) null), offset);
    assertEquals(offset.getRules().getValidOffsets((LocalDateTime) null), Arrays.asList(offset));
    assertEquals(offset.getRules().getTransition((LocalDateTime) null), null);
    assertEquals(offset.getRules().getTransitions().size(), 0);
    assertEquals(offset.getRules().getTransitionRules().size(), 0);
}
Also used : LocalDateTime(java.time.LocalDateTime) Instant(java.time.Instant) ZoneOffset(java.time.ZoneOffset) Test(org.testng.annotations.Test)

Example 7 with ZoneOffset

use of java.time.ZoneOffset in project jdk8u_jdk by JetBrains.

the class TCKZoneOffset method test_factory_string_UTC.

//-----------------------------------------------------------------------
// of(String)
//-----------------------------------------------------------------------
@Test
public void test_factory_string_UTC() {
    String[] values = new String[] { "Z", "+0", "+00", "+0000", "+00:00", "+000000", "+00:00:00", "-00", "-0000", "-00:00", "-000000", "-00:00:00" };
    for (int i = 0; i < values.length; i++) {
        ZoneOffset test = ZoneOffset.of(values[i]);
        assertSame(test, ZoneOffset.UTC);
    }
}
Also used : ZoneOffset(java.time.ZoneOffset) Test(org.testng.annotations.Test)

Example 8 with ZoneOffset

use of java.time.ZoneOffset in project jdk8u_jdk by JetBrains.

the class TCKZoneId method test_invalidPrefixOfOffset.

@Test(dataProvider = "prefixInvalid", expectedExceptions = java.lang.IllegalArgumentException.class)
public void test_invalidPrefixOfOffset(String prefix, String offset) {
    ZoneOffset zoff = ZoneOffset.of(offset);
    ZoneId zoneId = ZoneId.ofOffset(prefix, zoff);
    fail("should have thrown an exception for prefix: " + prefix);
}
Also used : ZoneId(java.time.ZoneId) ZoneOffset(java.time.ZoneOffset) Test(org.testng.annotations.Test)

Example 9 with ZoneOffset

use of java.time.ZoneOffset in project jdk8u_jdk by JetBrains.

the class TCKZoneOffset method test_compareTo.

//-----------------------------------------------------------------------
// compareTo()
//-----------------------------------------------------------------------
@Test
public void test_compareTo() {
    ZoneOffset offset1 = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3);
    ZoneOffset offset2 = ZoneOffset.ofHoursMinutesSeconds(2, 3, 4);
    assertTrue(offset1.compareTo(offset2) > 0);
    assertTrue(offset2.compareTo(offset1) < 0);
    assertTrue(offset1.compareTo(offset1) == 0);
    assertTrue(offset2.compareTo(offset2) == 0);
}
Also used : ZoneOffset(java.time.ZoneOffset) Test(org.testng.annotations.Test)

Example 10 with ZoneOffset

use of java.time.ZoneOffset in project jdk8u_jdk by JetBrains.

the class TCKZoneOffset method test_constant_MIN.

@Test
public void test_constant_MIN() {
    ZoneOffset test = ZoneOffset.MIN;
    doTestOffset(test, -18, 0, 0);
}
Also used : ZoneOffset(java.time.ZoneOffset) Test(org.testng.annotations.Test)

Aggregations

ZoneOffset (java.time.ZoneOffset)62 Test (org.testng.annotations.Test)35 LocalDateTime (java.time.LocalDateTime)9 ZoneRules (java.time.zone.ZoneRules)9 ZoneId (java.time.ZoneId)8 ZonedDateTime (java.time.ZonedDateTime)7 Instant (java.time.Instant)6 DateTimeFormatter (java.time.format.DateTimeFormatter)5 OffsetDateTime (java.time.OffsetDateTime)4 ZoneOffsetTransition (java.time.zone.ZoneOffsetTransition)4 Clock (java.time.Clock)3 LocalTime (java.time.LocalTime)2 ChronoField (java.time.temporal.ChronoField)2 Cache (com.github.benmanes.caffeine.cache.Cache)1 Caffeine (com.github.benmanes.caffeine.cache.Caffeine)1 DateTimeException (java.time.DateTimeException)1 DayOfWeek (java.time.DayOfWeek)1 Duration (java.time.Duration)1 LocalDate (java.time.LocalDate)1 Month (java.time.Month)1