Interface DateTimeParser
- All Known Implementing Classes:
CaseSensitivePrinterParser
,CharLiteralPrinterParser
,CompositePrinterParser
,FractionPrinterParser
,LocalizedPrinterParser
,NumberPrinterParser
,PadPrinterParserDecorator
,ReducedPrinterParser
,StrictLenientPrinterParser
,StringLiteralPrinterParser
,TextPrinterParser
,ZoneOffsetPrinterParser
,ZonePrinterParser
The parser may parse any piece of text from the input, storing the result
in the context. Typically, each individual parser will just parse one
field, such as the day-of-month, storing the value in the context.
Once the parse is complete, the caller will then convert the context
to a CalendricalMerger
to merge the parsed values to create the
desired object, such as a LocalDate
.
The parse position will be updated during the parse. Parsing will start at the specified index and the return value specifies the new parse position for the next parser. If an error occurs, the returned index will be negative and will have the error position encoded using the complement operator.
DateTimeParser is an interface and must be implemented with care to ensure other classes in the framework operate correctly. All instantiable implementations must be final, immutable and thread-safe.
The context is not a thread-safe object and a new instance will be created for each parse that occurs. The context must not be stored in an instance variable or shared with any other threads.
-
Method Summary
Modifier and TypeMethodDescriptionint
parse
(DateTimeParseContext context, String parseText, int position) Parses from the supplied text and position into the calendrical.
-
Method Details
-
parse
Parses from the supplied text and position into the calendrical.- Parameters:
context
- the context to use and parse into, not nullparseText
- the input text to parse, not nullposition
- the position to start parsing at, from 0 to the text length- Returns:
- the new parse position, where negative means an error with the error position encoded using the complement ~ operator
- Throws:
NullPointerException
- if the context or text is nullIndexOutOfBoundsException
- if the position is invalid
-