DateTimePrinterParser

Strategy for formatting/parsing date-time information. !(p) The printer may format any part, or the whole, of the input date-time object. Typically, a complete format is constructed from a number of smaller units, each outputting a single field. !(p) 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 resolve the parsed values to create the desired object, such as a {@code LocalDate}. !(p) 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.

@implSpec 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. !(p) The context is not a thread-safe object and a new instance will be created for each format that occurs. The context must not be stored _in an instance variable or shared with any other threads.

Members

Functions

format
bool format(DateTimePrintContext context, StringBuilder buf)

Prints the date-time object to the buffer. !(p) The context holds information to use during the format. It also contains the date-time information to be printed. !(p) The buffer must not be mutated beyond the content controlled by the implementation.

parse
int parse(DateTimeParseContext context, string text, int position)

Parses text into date-time information. !(p) The context holds information to use during the parse. It is also used to store the parsed date-time information.

toString
string toString()
Undocumented in source.

Meta