Interface DateTimeFormatterBuilder.DateTimePrinterParser
-
- All Known Implementing Classes:
DateTimeFormatterBuilder.CharLiteralPrinterParser,DateTimeFormatterBuilder.ChronoPrinterParser,DateTimeFormatterBuilder.CompositePrinterParser,DateTimeFormatterBuilder.DefaultingParser,DateTimeFormatterBuilder.FractionPrinterParser,DateTimeFormatterBuilder.InstantPrinterParser,DateTimeFormatterBuilder.LocalizedOffsetPrinterParser,DateTimeFormatterBuilder.LocalizedPrinterParser,DateTimeFormatterBuilder.NumberPrinterParser,DateTimeFormatterBuilder.OffsetIdPrinterParser,DateTimeFormatterBuilder.PadPrinterParserDecorator,DateTimeFormatterBuilder.ReducedPrinterParser,DateTimeFormatterBuilder.SettingsParser,DateTimeFormatterBuilder.StringLiteralPrinterParser,DateTimeFormatterBuilder.TextPrinterParser,DateTimeFormatterBuilder.WeekFieldsPrinterParser,DateTimeFormatterBuilder.ZoneIdPrinterParser,DateTimeFormatterBuilder.ZoneTextPrinterParser
- Enclosing class:
- DateTimeFormatterBuilder
static interface DateTimeFormatterBuilder.DateTimePrinterParserStrategy for printing/parsing date-time information.The printer may print any part, or the whole, of the input date-time object. Typically, a complete print is constructed from a number of smaller units, each outputting a single field.
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
DateTimeBuilderto merge the parsed values to create the desired object, such as aLocalDate.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.
Specification for implementors
This interface must be implemented with care to ensure other classes operate correctly. All implementations that can be instantiated must be final, immutable and thread-safe.The context is not a thread-safe object and a new instance will be created for each print that occurs. The context must not be stored in an instance variable or shared with any other threads.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description intparse(DateTimeParseContext context, java.lang.CharSequence text, int position)Parses text into date-time information.booleanprint(DateTimePrintContext context, java.lang.StringBuilder buf)Prints the date-time object to the buffer.
-
-
-
Method Detail
-
print
boolean print(DateTimePrintContext context, java.lang.StringBuilder buf)
Prints the date-time object to the buffer.The context holds information to use during the print. It also contains the date-time information to be printed.
The buffer must not be mutated beyond the content controlled by the implementation.
- Parameters:
context- the context to print using, not nullbuf- the buffer to append to, not null- Returns:
- false if unable to query the value from the date-time, true otherwise
- Throws:
DateTimeException- if the date-time cannot be printed successfully
-
parse
int parse(DateTimeParseContext context, java.lang.CharSequence text, int position)
Parses text into date-time information.The context holds information to use during the parse. It is also used to store the parsed date-time information.
- Parameters:
context- the context to use and parse into, not nulltext- 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:
java.lang.NullPointerException- if the context or text is nulljava.lang.IndexOutOfBoundsException- if the position is invalid
-
-