Package org.springframework.format.datetime.standard

# Class TemporalAccessorParser

java.lang.Object
org.springframework.format.datetime.standard.TemporalAccessorParser

All Implemented Interfaces:
  `Parser<TemporalAccessor>`

public final class TemporalAccessorParser extends Object implements 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

Constructors
Constructor
Description
`TemporalAccessorParser(Class<? extends TemporalAccessor> temporalAccessorType, DateTimeFormatter formatter)`
Create a new TemporalAccessorParser for the given TemporalAccessor type.

## Method Summary

Modifier and Type
Method
Description
`TemporalAccessor`
`parse(String text, Locale locale)`
Parse a text String to produce a T.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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

public TemporalAccessor parse(String text, Locale locale) throws ParseException
Description copied from interface: `Parser`
Parse a text String to produce a T.

Specified by:
  `parse` in interface `Parser<TemporalAccessor>`
Parameters:
  `text` - the text string
  `locale` - the current user locale
Returns:
  an instance of T
Throws:
  `ParseException` - when a parse exception occurs in a java.text parsing library