use of java.time.Year in project jdk8u_jdk by JetBrains.
the class TCKYear method now_ZoneId.
@Test
public void now_ZoneId() {
ZoneId zone = ZoneId.of("UTC+01:02:03");
Year expected = Year.now(Clock.system(zone));
Year test = Year.now(zone);
for (int i = 0; i < 100; i++) {
if (expected.equals(test)) {
return;
}
expected = Year.now(Clock.system(zone));
test = Year.now(zone);
}
assertEquals(test, expected);
}
use of java.time.Year in project jdk8u_jdk by JetBrains.
the class TCKYear method test_minusYear_zero_equals.
@Test
public void test_minusYear_zero_equals() {
Year base = Year.of(2007);
assertEquals(base.minusYears(0), base);
}
use of java.time.Year in project jdk8u_jdk by JetBrains.
the class TCKYear method test_factory_int_singleton.
//-----------------------------------------------------------------------
@Test
public void test_factory_int_singleton() {
for (int i = -4; i <= 2104; i++) {
Year test = Year.of(i);
assertEquals(test.getValue(), i);
assertEquals(Year.of(i), test);
}
}
use of java.time.Year in project jdk8u_jdk by JetBrains.
the class TCKYear method test_with.
//-----------------------------------------------------------------------
// with(TemporalField, long)
//-----------------------------------------------------------------------
@Test
public void test_with() {
Year base = Year.of(5);
Year result = base.with(ChronoField.ERA, 0);
assertEquals(result, base.with(IsoEra.of(0)));
int prolepticYear = IsoChronology.INSTANCE.prolepticYear(IsoEra.of(0), 5);
assertEquals(result.get(ChronoField.ERA), 0);
assertEquals(result.get(ChronoField.YEAR), prolepticYear);
assertEquals(result.get(ChronoField.YEAR_OF_ERA), 5);
result = base.with(ChronoField.YEAR, 10);
assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
assertEquals(result.get(ChronoField.YEAR), 10);
assertEquals(result.get(ChronoField.YEAR_OF_ERA), 10);
result = base.with(ChronoField.YEAR_OF_ERA, 20);
assertEquals(result.get(ChronoField.ERA), base.get(ChronoField.ERA));
assertEquals(result.get(ChronoField.YEAR), 20);
assertEquals(result.get(ChronoField.YEAR_OF_ERA), 20);
}
use of java.time.Year in project jdk8u_jdk by JetBrains.
the class TCKYear method test_atMonth_int.
//-----------------------------------------------------------------------
// atMonth(int)
//-----------------------------------------------------------------------
@Test
public void test_atMonth_int() {
Year test = Year.of(2008);
assertEquals(test.atMonth(6), YearMonth.of(2008, 6));
}
Aggregations