use of java.time.format.DateTimeFormatterBuilder in project streamsx.health by IBMStreams.
the class VinesToObservationParser method readResolve.
public Object readResolve() throws ObjectStreamException {
formatter = new DateTimeFormatterBuilder().appendPattern(DATE_TIME_PATTERN).toFormatter(Locale.ENGLISH);
isMappingEnabled = Boolean.parseBoolean(mappingEnabledSupplier.get());
try {
InputStream inputStream = Resources.getResource(MAPPING_FILE).openStream();
lookupTable = new VinesToStreamsCodeLookupTable(inputStream);
} catch (Exception e) {
ObjectStreamException ose = new ObjectStreamException() {
private static final long serialVersionUID = 1L;
};
ose.addSuppressed(e);
throw ose;
}
return this;
}
use of java.time.format.DateTimeFormatterBuilder in project jdk8u_jdk by JetBrains.
the class TCKChronoPrinterParser method setUp.
@BeforeMethod
public void setUp() {
builder = new DateTimeFormatterBuilder();
pos = new ParsePosition(0);
}
use of java.time.format.DateTimeFormatterBuilder in project jdk8u_jdk by JetBrains.
the class TCKDateTimeParseResolver method test_resolveTwoToDate.
@Test(dataProvider = "resolveTwoToDate")
public void test_resolveTwoToDate(TemporalField field1, long value1, TemporalField field2, long value2, LocalDate expectedDate) {
String str = value1 + " " + value2;
DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(field1).appendLiteral(' ').appendValue(field2).toFormatter();
TemporalAccessor accessor = f.parse(str);
assertEquals(accessor.query(TemporalQueries.localDate()), expectedDate);
assertEquals(accessor.query(TemporalQueries.localTime()), null);
}
use of java.time.format.DateTimeFormatterBuilder in project jdk8u_jdk by JetBrains.
the class TCKDateTimeParseResolver method test_fieldResolvesToChronoZonedDateTime_noOverrideChrono_matches.
//-------------------------------------------------------------------------
@Test
public void test_fieldResolvesToChronoZonedDateTime_noOverrideChrono_matches() {
ZonedDateTime zdt = ZonedDateTime.of(2010, 6, 30, 12, 30, 0, 0, EUROPE_PARIS);
DateTimeFormatter f = new DateTimeFormatterBuilder().appendValue(new ResolvingField(zdt)).toFormatter();
TemporalAccessor accessor = f.parse("1234567890");
assertEquals(accessor.query(TemporalQueries.localDate()), LocalDate.of(2010, 6, 30));
assertEquals(accessor.query(TemporalQueries.localTime()), LocalTime.of(12, 30));
assertEquals(accessor.query(TemporalQueries.chronology()), IsoChronology.INSTANCE);
assertEquals(accessor.query(TemporalQueries.zoneId()), EUROPE_PARIS);
}
use of java.time.format.DateTimeFormatterBuilder in project jdk8u_jdk by JetBrains.
the class TCKDateTimeParseResolver method test_resolveFourToTime.
@Test(dataProvider = "resolveFourToTime")
public void test_resolveFourToTime(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).parseDefaulting(NANO_OF_SECOND, nano).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, "ResolverStyle: " + s);
assertEquals(accessor.query(DateTimeFormatter.parsedExcessDays()), excessPeriod, "ResolverStyle: " + s);
} else {
try {
f.withResolverStyle(style).parse("");
fail();
} catch (DateTimeParseException ex) {
// expected
}
}
}
}
Aggregations