@UsesJava8 public final class TemporalAccessorParser extends Object implements Parser<TemporalAccessor>
Parser
implementation for a JSR-310 TemporalAccessor
,
using a DateTimeFormatter
) (the contextual one, if available).DateTimeContextHolder.getFormatter(java.time.format.DateTimeFormatter, java.util.Locale)
,
LocalDate.parse(CharSequence, java.time.format.DateTimeFormatter)
,
LocalTime.parse(CharSequence, java.time.format.DateTimeFormatter)
,
LocalDateTime.parse(CharSequence, java.time.format.DateTimeFormatter)
,
ZonedDateTime.parse(CharSequence, java.time.format.DateTimeFormatter)
,
OffsetDateTime.parse(CharSequence, java.time.format.DateTimeFormatter)
,
OffsetTime.parse(CharSequence, java.time.format.DateTimeFormatter)
Constructor and Description |
---|
TemporalAccessorParser(Class<? extends TemporalAccessor> temporalAccessorType,
DateTimeFormatter formatter)
Create a new TemporalAccessorParser for the given TemporalAccessor type.
|
Modifier and Type | Method and Description |
---|---|
TemporalAccessor |
parse(String text,
Locale locale)
Parse a text String to produce a T.
|
public TemporalAccessorParser(Class<? extends TemporalAccessor> temporalAccessorType, DateTimeFormatter formatter)
temporalAccessorType
- the specific TemporalAccessor class
(LocalDate, LocalTime, LocalDateTime, ZonedDateTime, OffsetDateTime, OffsetTime)formatter
- the base DateTimeFormatter instancepublic TemporalAccessor parse(String text, Locale locale) throws ParseException
Parser
parse
in interface Parser<TemporalAccessor>
text
- the text stringlocale
- the current user localeParseException
- when a parse exception occurs in a java.text parsing library