use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_withZoneSameLocal.
//-----------------------------------------------------------------------
// withZoneSameLocal(ZoneId)
//-----------------------------------------------------------------------
@Test
public void test_withZoneSameLocal() {
LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
ZonedDateTime test = base.withZoneSameLocal(ZONE_0200);
assertEquals(test.toLocalDateTime(), base.toLocalDateTime());
}
use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_toEpochSecond_afterEpoch.
//-----------------------------------------------------------------------
// toEpochSecond()
//-----------------------------------------------------------------------
@Test
public void test_toEpochSecond_afterEpoch() {
LocalDateTime ldt = LocalDateTime.of(1970, 1, 1, 0, 0).plusHours(1);
for (int i = 0; i < 100000; i++) {
ZonedDateTime a = ZonedDateTime.of(ldt, ZONE_PARIS);
assertEquals(a.toEpochSecond(), i);
ldt = ldt.plusSeconds(1);
}
}
use of java.time.LocalDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method factory_of_LocalDateTime_nullZone.
@Test(expectedExceptions = NullPointerException.class)
public void factory_of_LocalDateTime_nullZone() {
LocalDateTime base = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 500);
ZonedDateTime.of(base, null);
}
use of java.time.LocalDateTime 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.LocalDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_withZoneSameLocal_retainOffset1.
@Test
public void test_withZoneSameLocal_retainOffset1() {
// overlap
LocalDateTime ldt = LocalDateTime.of(2008, 11, 2, 1, 30, 59, 0);
ZonedDateTime base = ZonedDateTime.of(ldt, ZoneId.of("UTC-04:00"));
ZonedDateTime test = base.withZoneSameLocal(ZoneId.of("America/New_York"));
assertEquals(base.getOffset(), ZoneOffset.ofHours(-4));
assertEquals(test.getOffset(), ZoneOffset.ofHours(-4));
}
Aggregations