use of java.time.chrono.MinguoDate in project jdk8u_jdk by JetBrains.
the class TCKMinguoChronology method test_resolve_ymd_strict.
@Test(dataProvider = "resolve_ymd")
public void test_resolve_ymd_strict(int y, int m, int d, MinguoDate expected, Object smart, boolean strict) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR, (long) y);
fieldValues.put(ChronoField.MONTH_OF_YEAR, (long) m);
fieldValues.put(ChronoField.DAY_OF_MONTH, (long) d);
if (strict) {
MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
use of java.time.chrono.MinguoDate in project jdk8u_jdk by JetBrains.
the class TCKMinguoChronology method test_adjust_toLocalDate.
//-----------------------------------------------------------------------
// MinguoDate.with(Local*)
//-----------------------------------------------------------------------
@Test
public void test_adjust_toLocalDate() {
MinguoDate minguo = MinguoChronology.INSTANCE.date(99, 1, 4);
MinguoDate test = minguo.with(LocalDate.of(2012, 7, 6));
assertEquals(test, MinguoChronology.INSTANCE.date(101, 7, 6));
}
use of java.time.chrono.MinguoDate in project jdk8u_jdk by JetBrains.
the class TCKDateTimeParseResolver method test_fieldResolvesToChronoLocalDate_overrideChrono_matches.
@Test
public void test_fieldResolvesToChronoLocalDate_overrideChrono_matches() {
MinguoDate mdt = MinguoDate.of(100, 6, 30);
DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(mdt)).toFormatter();
f = f.withChronology(MinguoChronology.INSTANCE);
TemporalAccessor accessor = f.parse("1234567890");
assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.from(mdt));
assertEquals(accessor.query(TemporalQueries.localTime()), null);
assertEquals(accessor.query(TemporalQueries.chronology()), MinguoChronology.INSTANCE);
}
use of java.time.chrono.MinguoDate in project jdk8u_jdk by JetBrains.
the class TestReducedPrinter method test_minguoChrono_fixedWidth.
//-----------------------------------------------------------------------
public void test_minguoChrono_fixedWidth() throws Exception {
// ISO 2021 is Minguo 110
DateTimeFormatter f = getFormatterBaseDate(YEAR, 2, 2, 2021);
MinguoDate date = MinguoDate.of(109, 6, 30);
assertEquals(f.format(date), "09");
date = MinguoDate.of(110, 6, 30);
assertEquals(f.format(date), "10");
date = MinguoDate.of(199, 6, 30);
assertEquals(f.format(date), "99");
date = MinguoDate.of(200, 6, 30);
assertEquals(f.format(date), "00");
date = MinguoDate.of(209, 6, 30);
assertEquals(f.format(date), "09");
date = MinguoDate.of(210, 6, 30);
assertEquals(f.format(date), "10");
}
use of java.time.chrono.MinguoDate in project jdk8u_jdk by JetBrains.
the class TCKMinguoChronology method test_resolve_yd_strict.
@Test(dataProvider = "resolve_yd")
public void test_resolve_yd_strict(int y, int d, MinguoDate expected, boolean smart, boolean strict) {
Map<TemporalField, Long> fieldValues = new HashMap<>();
fieldValues.put(ChronoField.YEAR, (long) y);
fieldValues.put(ChronoField.DAY_OF_YEAR, (long) d);
if (strict) {
MinguoDate date = MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
assertEquals(date, expected);
assertEquals(fieldValues.size(), 0);
} else {
try {
MinguoChronology.INSTANCE.resolveDate(fieldValues, ResolverStyle.STRICT);
fail("Should have failed");
} catch (DateTimeException ex) {
// expected
}
}
}
Aggregations