use of java.time.format.DateTimeFormatterBuilder in project jdk8u_jdk by JetBrains.
the class TCKIsoFields method test_parse_parseLenientQuarter_LENIENT.
@Test(dataProvider = "parseLenientQuarter")
public void test_parse_parseLenientQuarter_LENIENT(String str, LocalDate expected, boolean smart) {
DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(YEAR).appendLiteral(':').appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral(':').appendValue(IsoFields.DAY_OF_QUARTER).toFormatter().withResolverStyle(ResolverStyle.LENIENT);
LocalDate parsed = LocalDate.parse(str, f);
assertEquals(parsed, expected);
}
use of java.time.format.DateTimeFormatterBuilder in project jdk8u_jdk by JetBrains.
the class TCKIsoFields method test_parse_parseLenientWeek_STRICT.
@Test(dataProvider = "parseLenientWeek", expectedExceptions = DateTimeParseException.class)
public void test_parse_parseLenientWeek_STRICT(String str, LocalDate expected, boolean smart) {
DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(IsoFields.WEEK_BASED_YEAR).appendLiteral(':').appendValue(IsoFields.WEEK_OF_WEEK_BASED_YEAR).appendLiteral(':').appendValue(DAY_OF_WEEK).toFormatter().withResolverStyle(ResolverStyle.STRICT);
LocalDate.parse(str, f);
}
use of java.time.format.DateTimeFormatterBuilder in project jdk8u_jdk by JetBrains.
the class TCKIsoFields method test_parse_parseLenientQuarter_SMART.
@Test(dataProvider = "parseLenientQuarter")
public void test_parse_parseLenientQuarter_SMART(String str, LocalDate expected, boolean smart) {
DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(YEAR).appendLiteral(':').appendValue(IsoFields.QUARTER_OF_YEAR).appendLiteral(':').appendValue(IsoFields.DAY_OF_QUARTER).toFormatter().withResolverStyle(ResolverStyle.SMART);
if (smart) {
LocalDate parsed = LocalDate.parse(str, f);
assertEquals(parsed, expected);
} else {
try {
LocalDate.parse(str, f);
fail("Should have failed");
} catch (DateTimeParseException ex) {
// expected
}
}
}
use of java.time.format.DateTimeFormatterBuilder in project jdk8u_jdk by JetBrains.
the class AbstractTestPrinterParser method setUp.
@BeforeMethod
public void setUp() {
buf = new StringBuilder();
builder = new DateTimeFormatterBuilder();
dta = ZonedDateTime.of(LocalDateTime.of(2011, 6, 30, 12, 30, 40, 0), ZoneId.of("Europe/Paris"));
locale = Locale.ENGLISH;
decimalStyle = DecimalStyle.STANDARD;
}
use of java.time.format.DateTimeFormatterBuilder in project jdk8u_jdk by JetBrains.
the class TCKDateTimeParseResolver method test_resolveFourToDate.
@Test(dataProvider = "resolveFourToDate")
public void test_resolveFourToDate(TemporalField field1, long value1, TemporalField field2, long value2, TemporalField field3, long value3, TemporalField field4, long value4, LocalDate expectedDate) {
String str = value1 + " " + value2 + " " + value3 + " " + value4;
DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field1).appendLiteral(' ').appendValue(field2).appendLiteral(' ').appendValue(field3).appendLiteral(' ').appendValue(field4).toFormatter();
TemporalAccessor accessor = f.parse(str);
assertEquals(accessor.query(TemporalQueries.localDate()), expectedDate);
assertEquals(accessor.query(TemporalQueries.localTime()), null);
}
Aggregations