Search in sources :

Example 56 with ZoneOffset

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

the class TCKZoneId method test_prefixOfOffset.

@Test(dataProvider = "prefixValid")
public void test_prefixOfOffset(String prefix, String offset) {
    ZoneOffset zoff = ZoneOffset.of(offset);
    ZoneId zoneId = ZoneId.ofOffset(prefix, zoff);
    assertEquals(zoneId.getId(), prefix + zoff.getId(), "in correct id for : " + prefix + ", zoff: " + zoff);
}
Also used : ZoneId(java.time.ZoneId) ZoneOffset(java.time.ZoneOffset) Test(org.testng.annotations.Test)

Example 57 with ZoneOffset

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

the class TCKZoneOffset method test_constant_MAX.

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

Example 58 with ZoneOffset

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

the class TCKZoneOffset method test_toString.

//-----------------------------------------------------------------------
// toString()
//-----------------------------------------------------------------------
@Test
public void test_toString() {
    ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(1, 0, 0);
    assertEquals(offset.toString(), "+01:00");
    offset = ZoneOffset.ofHoursMinutesSeconds(1, 2, 3);
    assertEquals(offset.toString(), "+01:02:03");
    offset = ZoneOffset.UTC;
    assertEquals(offset.toString(), "Z");
}
Also used : ZoneOffset(java.time.ZoneOffset) Test(org.testng.annotations.Test)

Example 59 with ZoneOffset

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

the class TCKMinguoChronology method test_MinguoDate.

@SuppressWarnings("unused")
@Test(dataProvider = "samples")
public void test_MinguoDate(MinguoDate minguoDate, LocalDate iso) {
    MinguoDate hd = minguoDate;
    ChronoLocalDateTime<MinguoDate> hdt = hd.atTime(LocalTime.NOON);
    ZoneOffset zo = ZoneOffset.ofHours(1);
    ChronoZonedDateTime<MinguoDate> hzdt = hdt.atZone(zo);
    hdt = hdt.plus(1, ChronoUnit.YEARS);
    hdt = hdt.plus(1, ChronoUnit.MONTHS);
    hdt = hdt.plus(1, ChronoUnit.DAYS);
    hdt = hdt.plus(1, ChronoUnit.HOURS);
    hdt = hdt.plus(1, ChronoUnit.MINUTES);
    hdt = hdt.plus(1, ChronoUnit.SECONDS);
    hdt = hdt.plus(1, ChronoUnit.NANOS);
    ChronoLocalDateTime<MinguoDate> a2 = hzdt.toLocalDateTime();
    MinguoDate a3 = a2.toLocalDate();
    MinguoDate a5 = hzdt.toLocalDate();
//System.out.printf(" d: %s, dt: %s; odt: %s; zodt: %s; a4: %s%n", date, hdt, hodt, hzdt, a5);
}
Also used : MinguoDate(java.time.chrono.MinguoDate) ZoneOffset(java.time.ZoneOffset) Test(org.testng.annotations.Test)

Example 60 with ZoneOffset

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

the class TCKDateTimeFormatterBuilder method test_appendOffset_format.

@Test(dataProvider = "offsetPatterns")
public void test_appendOffset_format(String pattern, int h, int m, int s, String expected) throws Exception {
    builder.appendOffset(pattern, "Z");
    DateTimeFormatter f = builder.toFormatter();
    ZoneOffset offset = ZoneOffset.ofHoursMinutesSeconds(h, m, s);
    assertEquals(f.format(offset), expected);
}
Also used : DateTimeFormatter(java.time.format.DateTimeFormatter) ZoneOffset(java.time.ZoneOffset) Test(org.testng.annotations.Test)

Aggregations

ZoneOffset (java.time.ZoneOffset)64 Test (org.testng.annotations.Test)35 LocalDateTime (java.time.LocalDateTime)10 ZoneId (java.time.ZoneId)10 ZoneRules (java.time.zone.ZoneRules)9 ZonedDateTime (java.time.ZonedDateTime)8 Instant (java.time.Instant)6 OffsetDateTime (java.time.OffsetDateTime)5 DateTimeFormatter (java.time.format.DateTimeFormatter)5 ZoneOffsetTransition (java.time.zone.ZoneOffsetTransition)4 Clock (java.time.Clock)3 LocalTime (java.time.LocalTime)3 Duration (java.time.Duration)2 LocalDate (java.time.LocalDate)2 OffsetTime (java.time.OffsetTime)2 ChronoField (java.time.temporal.ChronoField)2 TemporalAccessor (java.time.temporal.TemporalAccessor)2 List (java.util.List)2 Cache (com.github.benmanes.caffeine.cache.Cache)1 Caffeine (com.github.benmanes.caffeine.cache.Caffeine)1