public interface DateTimeParser
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.
Modifier and Type | Method and Description |
---|---|
int |
parse(DateTimeParseContext context,
String parseText,
int position)
Parses from the supplied text and position into the calendrical.
|
int parse(DateTimeParseContext context, String parseText, int position)
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 lengthNullPointerException
- if the context or text is nullIndexOutOfBoundsException
- if the position is invalidCopyright © 2014. All rights reserved.