use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_with_adjuster_LocalTime.
@Test
public void test_with_adjuster_LocalTime() {
ZonedDateTime base = ZonedDateTime.of(TEST_PARIS_OVERLAP_2008_10_26_02_30, ZONE_PARIS);
ZonedDateTime test = base.with(LocalTime.of(2, 29));
check(test, 2008, 10, 26, 2, 29, 0, 0, OFFSET_0200, ZONE_PARIS);
}
use of java.time.ZonedDateTime 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));
}
use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKDateTimeParseResolver method test_fieldResolvesToChronoZonedDateTime_overrideZone_matches.
@Test
public void test_fieldResolvesToChronoZonedDateTime_overrideZone_matches() {
ZonedDateTime zdt = ZonedDateTime.of(2010, 6, 30, 12, 30, 0, 0, EUROPE_PARIS);
DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(zdt)).toFormatter();
f = f.withZone(EUROPE_PARIS);
assertEquals(f.parse("1234567890", ZonedDateTime::from), zdt);
}
use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_equals_true.
//-----------------------------------------------------------------------
// equals() / hashCode()
//-----------------------------------------------------------------------
@Test(dataProvider = "sampleTimes")
public void test_equals_true(int y, int o, int d, int h, int m, int s, int n, ZoneId ignored) {
ZonedDateTime a = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100);
ZonedDateTime b = ZonedDateTime.of(dateTime(y, o, d, h, m, s, n), ZONE_0100);
assertEquals(a.equals(b), true);
assertEquals(a.hashCode() == b.hashCode(), true);
}
use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method now_ZoneId.
@Test
public void now_ZoneId() {
ZoneId zone = ZoneId.of("UTC+01:02:03");
ZonedDateTime expected = ZonedDateTime.now(Clock.system(zone));
ZonedDateTime test = ZonedDateTime.now(zone);
for (int i = 0; i < 100; i++) {
if (expected.equals(test)) {
return;
}
expected = ZonedDateTime.now(Clock.system(zone));
test = ZonedDateTime.now(zone);
}
assertEquals(test, expected);
}
Aggregations