use of java.time.format.ResolverStyle in project jdk8u_jdk by JetBrains.
the class TCKDateTimeParseResolver method test_resolveFourToDateTime.
@Test(dataProvider = "resolveFourToTime")
public void test_resolveFourToDateTime(ResolverStyle style, long hour, long min, long sec, long nano, LocalTime expectedTime, Period excessPeriod) {
DateTimeFormatter f = new DateTimeFormatterBuilder().parseDefaulting(YEAR, 2012).parseDefaulting(MONTH_OF_YEAR, 6).parseDefaulting(DAY_OF_MONTH, 30).parseDefaulting(HOUR_OF_DAY, hour).parseDefaulting(MINUTE_OF_HOUR, min).parseDefaulting(SECOND_OF_MINUTE, sec).parseDefaulting(NANO_OF_SECOND, nano).toFormatter();
ResolverStyle[] styles = (style != null ? new ResolverStyle[] { style } : ResolverStyle.values());
if (expectedTime != null && excessPeriod != null) {
LocalDate expectedDate = LocalDate.of(2012, 6, 30).plus(excessPeriod);
for (ResolverStyle s : styles) {
TemporalAccessor accessor = f.withResolverStyle(s).parse("");
assertEquals(accessor.query(TemporalQueries.localDate()), expectedDate, "ResolverStyle: " + s);
assertEquals(accessor.query(TemporalQueries.localTime()), expectedTime, "ResolverStyle: " + s);
assertEquals(accessor.query(DateTimeFormatter.parsedExcessDays()), Period.ZERO, "ResolverStyle: " + s);
}
}
}
use of java.time.format.ResolverStyle in project jdk8u_jdk by JetBrains.
the class TCKInstantPrinterParser method test_parse_endOfDay.
@Test
public void test_parse_endOfDay() {
Instant expected = OffsetDateTime.of(1970, 2, 4, 0, 0, 0, 0, ZoneOffset.UTC).toInstant();
DateTimeFormatter f = new DateTimeFormatterBuilder().appendInstant(-1).toFormatter();
for (ResolverStyle style : ResolverStyle.values()) {
TemporalAccessor parsed = f.withResolverStyle(style).parse("1970-02-03T24:00:00Z");
assertEquals(parsed.query(Instant::from), expected);
assertEquals(parsed.query(DateTimeFormatter.parsedExcessDays()), Period.ZERO);
assertEquals(parsed.query(DateTimeFormatter.parsedLeapSecond()), Boolean.FALSE);
}
}
use of java.time.format.ResolverStyle in project jdk8u_jdk by JetBrains.
the class TCKHijrahChronology method data_resolve_styleByEra.
//-----------------------------------------------------------------------
// Tests for HijrahChronology resolve
//-----------------------------------------------------------------------
@DataProvider(name = "resolve_styleByEra")
Object[][] data_resolve_styleByEra() {
Object[][] result = new Object[ResolverStyle.values().length * HijrahEra.values().length][];
int i = 0;
for (ResolverStyle style : ResolverStyle.values()) {
for (HijrahEra era : HijrahEra.values()) {
result[i++] = new Object[] { style, era };
}
}
return result;
}
use of java.time.format.ResolverStyle in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method data_resolve_styles.
@DataProvider(name = "resolve_styles")
Object[][] data_resolve_styles() {
Object[][] result = new Object[ResolverStyle.values().length][];
int i = 0;
for (ResolverStyle style : ResolverStyle.values()) {
result[i++] = new Object[] { style };
}
return result;
}
use of java.time.format.ResolverStyle in project jdk8u_jdk by JetBrains.
the class TCKJapaneseChronology method data_resolve_styleByEra.
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
@DataProvider(name = "resolve_styleByEra")
Object[][] data_resolve_styleByEra() {
Object[][] result = new Object[ResolverStyle.values().length * JapaneseEra.values().length][];
int i = 0;
for (ResolverStyle style : ResolverStyle.values()) {
for (JapaneseEra era : JapaneseEra.values()) {
result[i++] = new Object[] { style, era };
}
}
return result;
}
Aggregations