Top Description Fields Constructors Methods
org.springframework.format.datetime.standard

public final Class TemporalAccessorParser

extends Object
implements Parser<TemporalAccessor>
Class Inheritance
All Implemented Interfaces
org.springframework.format.Parser
Imports
java.text.ParseException, java.time.Instant, .LocalDate, .LocalDateTime, .LocalTime, .MonthDay, .OffsetDateTime, .OffsetTime, .YearMonth, .ZonedDateTime, java.time.format.DateTimeFormatter, .DateTimeParseException, java.time.temporal.TemporalAccessor, java.util.Locale, org.springframework.format.Parser, org.springframework.lang.Nullable, org.springframework.util.ObjectUtils

Parser implementation for a JSR-310 java.time.temporal.TemporalAccessor, using a java.time.format.DateTimeFormatter (the contextual one, if available).
Authors
Juergen Hoeller, Sam Brannen, Kazuki Shimizu
Since
4.0
See Also
DateTimeContextHolder#getFormatter, java.time.LocalDate#parse(CharSequence, java.time.format.DateTimeFormatter), java.time.LocalTime#parse(CharSequence, java.time.format.DateTimeFormatter), java.time.LocalDateTime#parse(CharSequence, java.time.format.DateTimeFormatter), java.time.ZonedDateTime#parse(CharSequence, java.time.format.DateTimeFormatter), java.time.OffsetDateTime#parse(CharSequence, java.time.format.DateTimeFormatter), java.time.OffsetTime#parse(CharSequence, java.time.format.DateTimeFormatter), java.time.YearMonth#parse(CharSequence, java.time.format.DateTimeFormatter), java.time.MonthDay#parse(CharSequence, java.time.format.DateTimeFormatter)

Field Summary

Modifier and TypeField and Description
private final String[]
private final DateTimeFormatter
private final Object
private final Class<? extends TemporalAccessor>

Constructor Summary

AccessConstructor and Description
public
TemporalAccessorParser(Class<? extends TemporalAccessor>
the specific TemporalAccessor class (LocalDate, LocalTime, LocalDateTime, ZonedDateTime, OffsetDateTime, OffsetTime)
temporalAccessorType
,
DateTimeFormatter
the base DateTimeFormatter instance
formatter
)

Create a new TemporalAccessorParser for the given TemporalAccessor type.

pack-priv
TemporalAccessorParser(Class<? extends TemporalAccessor> temporalAccessorType, DateTimeFormatter formatter, String[] fallbackPatterns, Object source)

Method Summary

Modifier and TypeMethod and Description
private TemporalAccessor
private TemporalAccessor
doParse(String text, Locale locale, DateTimeFormatter formatter)

public TemporalAccessor
parse(String
the text string
text
,
Locale
the current user locale
locale
)

Implements org.springframework.format.Parser.parse.

Parse a text String to produce a T.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fallbackPatternsback to summary
private final String[] fallbackPatterns
Annotations
@Nullable
formatterback to summary
private final DateTimeFormatter formatter
sourceback to summary
private final Object source
Annotations
@Nullable
temporalAccessorTypeback to summary
private final Class<? extends TemporalAccessor> temporalAccessorType

Constructor Detail

TemporalAccessorParserback to summary
public TemporalAccessorParser(Class<? extends TemporalAccessor> temporalAccessorType, DateTimeFormatter formatter)

Create a new TemporalAccessorParser for the given TemporalAccessor type.

Parameters
temporalAccessorType:Class<? extends TemporalAccessor>

the specific TemporalAccessor class (LocalDate, LocalTime, LocalDateTime, ZonedDateTime, OffsetDateTime, OffsetTime)

formatter:DateTimeFormatter

the base DateTimeFormatter instance

TemporalAccessorParserback to summary
pack-priv TemporalAccessorParser(Class<? extends TemporalAccessor> temporalAccessorType, DateTimeFormatter formatter, String[] fallbackPatterns, Object source)

Method Detail

defaultParseback to summary
private TemporalAccessor defaultParse(String text) throws DateTimeParseException
doParseback to summary
private TemporalAccessor doParse(String text, Locale locale, DateTimeFormatter formatter) throws DateTimeParseException
parseback to summary
public TemporalAccessor parse(String text, Locale locale) throws ParseException

Implements org.springframework.format.Parser.parse.

Doc from org.springframework.format.Parser.parse.

Parse a text String to produce a T.

Parameters
text:String

the text string

locale:Locale

the current user locale

Returns:TemporalAccessor

an instance of T

Annotations
@Override
Exceptions
ParseException:
when a parse exception occurs in a java.text parsing library