use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method now_Clock_allSecsInDay_beforeEpoch.
@Test
public void now_Clock_allSecsInDay_beforeEpoch() {
LocalTime expected = LocalTime.MIDNIGHT.plusNanos(123456789L);
for (int i = -1; i >= -(24 * 60 * 60); i--) {
Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L);
Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
ZonedDateTime test = ZonedDateTime.now(clock);
assertEquals(test.getYear(), 1969);
assertEquals(test.getMonth(), Month.DECEMBER);
assertEquals(test.getDayOfMonth(), 31);
expected = expected.minusSeconds(1);
assertEquals(test.toLocalTime(), expected);
assertEquals(test.getOffset(), ZoneOffset.UTC);
assertEquals(test.getZone(), ZoneOffset.UTC);
}
}
use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_until_gap.
@Test
public void test_until_gap() {
ZonedDateTime before = TEST_PARIS_GAP_2008_03_30_02_30.withHour(0).withMinute(0).atZone(ZONE_PARIS);
ZonedDateTime after = TEST_PARIS_GAP_2008_03_30_02_30.withHour(0).withMinute(0).plusDays(1).atZone(ZONE_PARIS);
assertEquals(before.until(after, HOURS), 23);
assertEquals(before.until(after, DAYS), 1);
}
use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_toEpochSecond_UTC.
@Test(dataProvider = "toInstant")
public void test_toEpochSecond_UTC(LocalDateTime ldt, long expectedEpSec, int expectedNos) {
ZonedDateTime dt = ldt.atZone(ZoneOffset.UTC);
assertEquals(dt.toEpochSecond(), expectedEpSec);
}
use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_withZoneSameLocal_null.
@Test(expectedExceptions = NullPointerException.class)
public void test_withZoneSameLocal_null() {
LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
base.withZoneSameLocal(null);
}
use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method factory_ofInstant_Instant_inGap.
@Test
public void factory_ofInstant_Instant_inGap() {
Instant instant = TEST_PARIS_GAP_2008_03_30_02_30.toInstant(OFFSET_0100);
ZonedDateTime test = ZonedDateTime.ofInstant(instant, ZONE_PARIS);
// one hour later in summer offset
check(test, 2008, 3, 30, 3, 30, 0, 0, OFFSET_0200, ZONE_PARIS);
}
Aggregations