DateTimeParseContext

Context object used during date and time parsing. !(p) This class represents the current state of the parse. It has the ability to store and retrieve the parsed values and manage optional segments. It also provides key information to the parsing methods. !(p) Once parsing is complete, the {@link #toUnresolved()} is used to obtain the unresolved result data. The {@link #toResolved()} is used to obtain the resolved result.

@implSpec This class is a mutable context intended for use from a single thread. Usage of the class is thread-safe within standard parsing as a new instance of this class is automatically created for each parse and parsing is single-threaded

@since 1.8

Constructors

this
this()
Undocumented in source.
this
this(DateTimeFormatter formatter)

Creates a new instance of the context.

Members

Functions

addChronoChangedListener
void addChronoChangedListener(Consumer!(Chronology) listener)

Adds a Consumer!(Chronology) to the list of listeners to be notified if the Chronology changes. @param listener a Consumer!(Chronology) to be called when Chronology changes

charEquals
bool charEquals(char ch1, char ch2)

Helper to compare two {@code char}. This uses {@link #isCaseSensitive()}.

copy
DateTimeParseContext copy()

Creates a copy of this context. This retains the case sensitive and strict flags.

endOptional
void endOptional(bool successful)

Ends the parsing of an optional segment of the input.

getDecimalStyle
DecimalStyle getDecimalStyle()

Gets the DecimalStyle. !(p) The DecimalStyle controls the numeric parsing.

getEffectiveChronology
Chronology getEffectiveChronology()

Gets the effective chronology during parsing.

getLocale
Locale getLocale()

Gets the locale. !(p) This locale is used to control localization _in the parse except where localization is controlled by the DecimalStyle.

getParsed
Long getParsed(TemporalField field)

Gets the first value that was parsed for the specified field. !(p) This searches the results of the parse, returning the first value found for the specified field. No attempt is made to derive a value. The field may have an _out of range value. For example, the day-of-month might be set to 50, or the hour to 1000.

isCaseSensitive
bool isCaseSensitive()

Checks if parsing is case sensitive.

isStrict
bool isStrict()

Checks if parsing is strict. !(p) Strict parsing requires exact matching of the text and sign styles.

setCaseSensitive
void setCaseSensitive(bool caseSensitive)

Sets whether the parsing is case sensitive or not.

setParsed
void setParsed(Chronology chrono)

Stores the parsed chronology. !(p) This stores the chronology that has been parsed. No validation is performed other than ensuring it is not null. !(p) The list of listeners is copied and cleared so that each listener is called only once. A listener can add itself again if it needs to be notified of future changes.

setParsed
void setParsed(ZoneId zone)

Stores the parsed zone. !(p) This stores the zone that has been parsed. No validation is performed other than ensuring it is not null.

setParsedField
int setParsedField(TemporalField field, long value, int errorPos, int successPos)

Stores the parsed field. !(p) This stores a field-value pair that has been parsed. The value stored may be _out of range for the field - no checks are performed.

setParsedLeapSecond
void setParsedLeapSecond()

Stores the parsed leap second.

setStrict
void setStrict(bool strict)

Sets whether parsing is strict or lenient.

startOptional
void startOptional()

Starts the parsing of an optional segment of the input.

subSequenceEquals
bool subSequenceEquals(string cs1, int offset1, string cs2, int offset2, int length)

Helper to compare two {@code CharSequence} instances. This uses {@link #isCaseSensitive()}.

toResolved
TemporalAccessor toResolved(ResolverStyle resolverStyle, Set!(TemporalField) resolverFields)

Gets the resolved result of the parse.

toString
string toString()

Returns a string version of the context for debugging.

toUnresolved
Parsed toUnresolved()

Gets the unresolved result of the parse.

Static functions

charEqualsIgnoreCase
bool charEqualsIgnoreCase(char c1, char c2)

Compares two characters ignoring case.

Meta