use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_withEarlierOffsetAtOverlap_atOverlap.
@Test
public void test_withEarlierOffsetAtOverlap_atOverlap() {
ZonedDateTime base = ZonedDateTime.ofStrict(TEST_PARIS_OVERLAP_2008_10_26_02_30, OFFSET_0100, ZONE_PARIS);
ZonedDateTime test = base.withEarlierOffsetAtOverlap();
// offset changed to earlier
assertEquals(test.getOffset(), OFFSET_0200);
// date-time not changed
assertEquals(test.toLocalDateTime(), base.toLocalDateTime());
}
use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method now_Clock_allSecsInDay_utc.
@Test
public void now_Clock_allSecsInDay_utc() {
for (int i = 0; i < (2 * 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(), 1970);
assertEquals(test.getMonth(), Month.JANUARY);
assertEquals(test.getDayOfMonth(), (i < 24 * 60 * 60 ? 1 : 2));
assertEquals(test.getHour(), (i / (60 * 60)) % 24);
assertEquals(test.getMinute(), (i / 60) % 60);
assertEquals(test.getSecond(), i % 60);
assertEquals(test.getNano(), 123456789);
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_withNanoOfSecond_noChange.
@Test
public void test_withNanoOfSecond_noChange() {
ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100);
ZonedDateTime test = base.withNano(500);
assertEquals(test, base);
}
use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_with_adjuster_OffsetDateTime_invalidOffsetIgnored.
@Test
public void test_with_adjuster_OffsetDateTime_invalidOffsetIgnored() {
// ODT has invalid offset for ZDT, so only LDT is set
OffsetDateTime odt = TEST_LOCAL_2008_06_30_11_30_59_500.atOffset(OFFSET_0130);
ZonedDateTime zdt = TEST_PARIS_OVERLAP_2008_10_26_02_30.atZone(ZONE_PARIS);
ZonedDateTime test = zdt.with(odt);
assertEquals(test.toLocalDateTime(), TEST_LOCAL_2008_06_30_11_30_59_500);
assertEquals(test.getOffset(), zdt.getOffset());
}
use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_minusMinutes_minutes.
@Test
public void test_minusMinutes_minutes() {
LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
ZonedDateTime test = base.minusMinutes(30);
assertEquals(test, ZonedDateTime.of(ldt.minusMinutes(30), ZONE_0100));
}
Aggregations