use of java.time.format.ResolverStyle in project jdk8u_jdk by JetBrains.
the class TCKDateTimeParseResolver method test_resolveThreeToTime.
@Test(dataProvider = "resolveFourToTime")
public void test_resolveThreeToTime(ResolverStyle style, long hour, long min, long sec, long nano, LocalTime expectedTime, Period excessPeriod) {
DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(HOUR_OF_DAY, hour).parseDefaulting(MINUTE_OF_HOUR, min).parseDefaulting(SECOND_OF_MINUTE, sec).toFormatter();
ResolverStyle[] styles = (style != null ? new ResolverStyle[] { style } : ResolverStyle.values());
for (ResolverStyle s : styles) {
if (expectedTime != null) {
TemporalAccessor accessor = f.withResolverStyle(s).parse("");
assertEquals(accessor.query(TemporalQueries.localDate()), null, "ResolverStyle: " + s);
assertEquals(accessor.query(TemporalQueries.localTime()), expectedTime.minusNanos(nano), "ResolverStyle: " + s);
assertEquals(accessor.query(DateTimeFormatter.parsedExcessDays()), excessPeriod, "ResolverStyle: " + s);
} else {
try {
f.withResolverStyle(style).parse("");
fail();
} catch (DateTimeParseException ex) {
// expected
}
}
}
}
Aggregations