Class DateTimeParseContext.Parsed
- java.lang.Object
-
- org.threeten.bp.jdk8.DefaultInterfaceTemporalAccessor
-
- org.threeten.bp.format.DateTimeParseContext.Parsed
-
- All Implemented Interfaces:
TemporalAccessor
- Enclosing class:
- DateTimeParseContext
final class DateTimeParseContext.Parsed extends DefaultInterfaceTemporalAccessor
Temporary store of parsed data.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.util.List<java.lang.Object[]>callbacks(package private) Chronologychrono(package private) PeriodexcessDays(package private) java.util.Map<TemporalField,java.lang.Long>fieldValues(package private) booleanleapSecond(package private) ZoneIdzone
-
Constructor Summary
Constructors Modifier Constructor Description privateParsed()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected DateTimeParseContext.Parsedcopy()intget(TemporalField field)Gets the value of the specified field as anint.longgetLong(TemporalField field)Gets the value of the specified field as along.booleanisSupported(TemporalField field)Checks if the specified field is supported.<R> Rquery(TemporalQuery<R> query)Queries this date-time.(package private) DateTimeBuildertoBuilder()Returns aDateTimeBuilderthat can be used to interpret the results of the parse.java.lang.StringtoString()-
Methods inherited from class org.threeten.bp.jdk8.DefaultInterfaceTemporalAccessor
range
-
-
-
-
Field Detail
-
chrono
Chronology chrono
-
zone
ZoneId zone
-
fieldValues
final java.util.Map<TemporalField,java.lang.Long> fieldValues
-
leapSecond
boolean leapSecond
-
excessDays
Period excessDays
-
callbacks
java.util.List<java.lang.Object[]> callbacks
-
-
Method Detail
-
copy
protected DateTimeParseContext.Parsed copy()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isSupported
public boolean isSupported(TemporalField field)
Description copied from interface:TemporalAccessorChecks if the specified field is supported.This checks if the date-time can be queried for the specified field. If false, then calling the
rangeandgetmethods will throw an exception.Specification for implementors
Implementations must check and handle all fields defined inChronoField. If the field is supported, then true is returned, otherwise falseIf the field is not a
ChronoField, then the result of this method is obtained by invokingTemporalField.isSupportedBy(TemporalAccessor)passingthisas the argument.Implementations must not alter this object.
- Parameters:
field- the field to check, null returns false- Returns:
- true if this date-time can be queried for the field, false if not
-
get
public int get(TemporalField field)
Description copied from interface:TemporalAccessorGets the value of the specified field as anint.This queries the date-time for the value for the specified field. The returned value will always be within the valid range of values for the field. If the date-time cannot return the value, because the field is unsupported or for some other reason, an exception will be thrown.
Specification for implementors
Implementations must check and handle all fields defined inChronoField. If the field is supported and has anintrange, then the value of the field must be returned. If unsupported, then aDateTimeExceptionmust be thrown.If the field is not a
ChronoField, then the result of this method is obtained by invokingTemporalField.getFrom(TemporalAccessor)passingthisas the argument.Implementations must not alter either this object.
- Specified by:
getin interfaceTemporalAccessor- Overrides:
getin classDefaultInterfaceTemporalAccessor- Parameters:
field- the field to get, not null- Returns:
- the value for the field, within the valid range of values
-
getLong
public long getLong(TemporalField field)
Description copied from interface:TemporalAccessorGets the value of the specified field as along.This queries the date-time for the value for the specified field. The returned value may be outside the valid range of values for the field. If the date-time cannot return the value, because the field is unsupported or for some other reason, an exception will be thrown.
Specification for implementors
Implementations must check and handle all fields defined inChronoField. If the field is supported, then the value of the field must be returned. If unsupported, then aDateTimeExceptionmust be thrown.If the field is not a
ChronoField, then the result of this method is obtained by invokingTemporalField.getFrom(TemporalAccessor)passingthisas the argument.Implementations must not alter either this object.
- Parameters:
field- the field to get, not null- Returns:
- the value for the field
-
query
public <R> R query(TemporalQuery<R> query)
Description copied from interface:TemporalAccessorQueries this date-time.This queries this date-time using the specified query strategy object.
Queries are a key tool for extracting information from date-times. They exists to externalize the process of querying, permitting different approaches, as per the strategy design pattern. Examples might be a query that checks if the date is the day before February 29th in a leap year, or calculates the number of days to your next birthday.
The most common query implementations are method references, such as
LocalDate::fromandZoneId::from. Further implementations are onTemporalQueries. Queries may also be defined by applications.Specification for implementors
Implementations of this method must behave as follows:public <R> R query(TemporalQuery<R> type) { // only include an if statement if the implementation can return it if (query == TemporalQueries.zoneId()) return // the ZoneId if (query == TemporalQueries.chronology()) return // the Chrono if (query == TemporalQueries.precision()) return // the precision // call default method return super.query(query); }- Specified by:
queryin interfaceTemporalAccessor- Overrides:
queryin classDefaultInterfaceTemporalAccessor- Type Parameters:
R- the type of the result- Parameters:
query- the query to invoke, not null- Returns:
- the query result, null may be returned (defined by the query)
-
toBuilder
DateTimeBuilder toBuilder()
Returns aDateTimeBuilderthat can be used to interpret the results of the parse.This method is typically used once parsing is complete to obtain the parsed data. Parsing will typically result in separate fields, such as year, month and day. The returned builder can be used to combine the parsed data into meaningful objects such as
LocalDate, potentially applying complex processing to handle invalid parsed data.- Returns:
- a new builder with the results of the parse, not null
-
-