use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_plusMonths.
//-----------------------------------------------------------------------
// plusMonths()
//-----------------------------------------------------------------------
@Test
public void test_plusMonths() {
LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
ZonedDateTime test = base.plusMonths(1);
assertEquals(test, ZonedDateTime.of(ldt.plusMonths(1), ZONE_0100));
}
use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method factory_parse_formatter.
//-----------------------------------------------------------------------
// parse(DateTimeFormatter)
//-----------------------------------------------------------------------
@Test
public void factory_parse_formatter() {
DateTimeFormatter f = DateTimeFormatter.ofPattern("y M d H m s VV");
ZonedDateTime test = ZonedDateTime.parse("2010 12 3 11 30 0 Europe/London", f);
assertEquals(test, ZonedDateTime.of(LocalDateTime.of(2010, 12, 3, 11, 30), ZoneId.of("Europe/London")));
}
use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_with_adjuster_OffsetDateTime_retainOffsetInOverlap1.
@Test
public void test_with_adjuster_OffsetDateTime_retainOffsetInOverlap1() {
// ODT will be a valid ZDT for the zone, so must be retained exactly
OffsetDateTime odt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atOffset(OFFSET_0100);
ZonedDateTime zdt = TEST_LOCAL_2008_06_30_11_30_59_500.atZone(ZONE_PARIS);
ZonedDateTime test = zdt.with(odt);
assertEquals(test.toOffsetDateTime(), odt);
}
use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method now_Clock_allSecsInDay_zone.
@Test
public void now_Clock_allSecsInDay_zone() {
ZoneId zone = ZoneId.of("Europe/London");
for (int i = 0; i < (2 * 24 * 60 * 60); i++) {
Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L);
ZonedDateTime expected = ZonedDateTime.ofInstant(instant, zone);
Clock clock = Clock.fixed(expected.toInstant(), zone);
ZonedDateTime test = ZonedDateTime.now(clock);
assertEquals(test, expected);
}
}
use of java.time.ZonedDateTime 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());
}
Aggregations