Class TemporalAccessorParser
java.lang.Object
org.springframework.format.datetime.standard.TemporalAccessorParser
- All Implemented Interfaces:
Parser<TemporalAccessor>
Parser
implementation for a JSR-310 TemporalAccessor
,
using a DateTimeFormatter
(the contextual one, if available).- Since:
- 4.0
- Author:
- Juergen Hoeller, Sam Brannen, Kazuki Shimizu
- See Also:
-
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)
YearMonth.parse(CharSequence, java.time.format.DateTimeFormatter)
MonthDay.parse(CharSequence, java.time.format.DateTimeFormatter)
-
Constructor Summary
ConstructorDescriptionTemporalAccessorParser
(Class<? extends TemporalAccessor> temporalAccessorType, DateTimeFormatter formatter) Create a new TemporalAccessorParser for the given TemporalAccessor type. -
Method Summary
Modifier and TypeMethodDescriptionParse a text String to produce a T.
-
Constructor Details
-
TemporalAccessorParser
public TemporalAccessorParser(Class<? extends TemporalAccessor> temporalAccessorType, DateTimeFormatter formatter) Create a new TemporalAccessorParser for the given TemporalAccessor type.- Parameters:
temporalAccessorType
- the specific TemporalAccessor class (LocalDate, LocalTime, LocalDateTime, ZonedDateTime, OffsetDateTime, OffsetTime)formatter
- the base DateTimeFormatter instance
-
-
Method Details
-
parse
Description copied from interface:Parser
Parse a text String to produce a T.- Specified by:
parse
in interfaceParser<TemporalAccessor>
- Parameters:
text
- the text stringlocale
- the current user locale- Returns:
- an instance of T
- Throws:
ParseException
- when a parse exception occurs in a java.text parsing library
-