public abstract class AbstractPartial extends java.lang.Object implements ReadablePartial, java.lang.Comparable<ReadablePartial>
Calculations on are performed using a Chronology.
This chronology is set to be in the UTC time zone for all calculations.
The methods on this class use ReadablePartial.size(),
getField(int, Chronology) and
ReadablePartial.getValue(int) to calculate their results.
Subclasses may have a better implementation.
AbstractPartial allows subclasses may be mutable and not thread-safe.
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(ReadablePartial other)
Compares this partial with another returning an integer
indicating the order.
|
boolean |
equals(java.lang.Object partial)
Compares this ReadablePartial with another returning true if the chronology,
field types and values are equal.
|
int |
get(DateTimeFieldType type)
Get the value of one of the fields of a datetime.
|
DateTimeField |
getField(int index)
Gets the field at the specifed index.
|
DateTimeField[] |
getFields()
Gets an array of the fields that this partial supports.
|
DateTimeFieldType |
getFieldType(int index)
Gets the field type at the specifed index.
|
DateTimeFieldType[] |
getFieldTypes()
Gets an array of the field types that this partial supports.
|
int[] |
getValues()
Gets an array of the value of each of the fields that this partial supports.
|
int |
hashCode()
Gets a hash code for the ReadablePartial that is compatible with the
equals method.
|
int |
indexOf(DateTimeFieldType type)
Gets the index of the specified field, or -1 if the field is unsupported.
|
boolean |
isAfter(ReadablePartial partial)
Is this partial later than the specified partial.
|
boolean |
isBefore(ReadablePartial partial)
Is this partial earlier than the specified partial.
|
boolean |
isEqual(ReadablePartial partial)
Is this partial the same as the specified partial.
|
boolean |
isSupported(DateTimeFieldType type)
Checks whether the field specified is supported by this partial.
|
DateTime |
toDateTime(ReadableInstant baseInstant)
Resolves this partial against another complete instant to create a new
full instant.
|
java.lang.String |
toString(DateTimeFormatter formatter)
Uses the specified formatter to convert this partial to a String.
|
getClass, notify, notifyAll, toString, wait, wait, waitgetChronology, getValue, size, toStringpublic DateTimeFieldType getFieldType(int index)
getFieldType in interface ReadablePartialindex - the indexjava.lang.IndexOutOfBoundsException - if the index is invalidpublic DateTimeFieldType[] getFieldTypes()
The fields are returned largest to smallest, for example Hour, Minute, Second.
public DateTimeField getField(int index)
getField in interface ReadablePartialindex - the indexjava.lang.IndexOutOfBoundsException - if the index is invalidpublic DateTimeField[] getFields()
The fields are returned largest to smallest, for example Hour, Minute, Second.
public int[] getValues()
The fields are returned largest to smallest, for example Hour, Minute, Second.
Each value corresponds to the same array index as getFields()
public int get(DateTimeFieldType type)
The field specified must be one of those that is supported by the partial.
get in interface ReadablePartialtype - a DateTimeFieldType instance that is supported by this partialjava.lang.IllegalArgumentException - if the field is null or not supportedpublic boolean isSupported(DateTimeFieldType type)
isSupported in interface ReadablePartialtype - the type to check, may be null which returns falsepublic int indexOf(DateTimeFieldType type)
type - the type to check, may be null which returns -1public DateTime toDateTime(ReadableInstant baseInstant)
For example, if this partial represents a time, then the result of this method will be the datetime from the specified base instant plus the time from this partial.
toDateTime in interface ReadablePartialbaseInstant - the instant that provides the missing fields, null means nowpublic boolean equals(java.lang.Object partial)
equals in interface ReadablePartialequals in class java.lang.Objectpartial - an object to check againstpublic int hashCode()
hashCode in interface ReadablePartialhashCode in class java.lang.Objectpublic int compareTo(ReadablePartial other)
The fields are compared in order, from largest to smallest. The first field that is non-equal is used to determine the result.
The specified object must be a partial instance whose field types match those of this partial.
NOTE: Prior to v2.0, the Comparable interface was only implemented
in this class and not in the ReadablePartial interface.
compareTo in interface java.lang.Comparable<ReadablePartial>other - an object to check againstjava.lang.ClassCastException - if the partial is the wrong class
or if it has field types that don't matchjava.lang.NullPointerException - if the partial is nullpublic boolean isAfter(ReadablePartial partial)
The fields are compared in order, from largest to smallest. The first field that is non-equal is used to determine the result.
You may not pass null into this method. This is because you need a time zone to accurately determine the current date.
partial - a partial to check against, must not be nulljava.lang.IllegalArgumentException - if the specified partial is nulljava.lang.ClassCastException - if the partial has field types that don't matchpublic boolean isBefore(ReadablePartial partial)
The fields are compared in order, from largest to smallest. The first field that is non-equal is used to determine the result.
You may not pass null into this method. This is because you need a time zone to accurately determine the current date.
partial - a partial to check against, must not be nulljava.lang.IllegalArgumentException - if the specified partial is nulljava.lang.ClassCastException - if the partial has field types that don't matchpublic boolean isEqual(ReadablePartial partial)
The fields are compared in order, from largest to smallest. If all fields are equal, the result is true.
You may not pass null into this method. This is because you need a time zone to accurately determine the current date.
partial - a partial to check against, must not be nulljava.lang.IllegalArgumentException - if the specified partial is nulljava.lang.ClassCastException - if the partial has field types that don't matchpublic java.lang.String toString(DateTimeFormatter formatter)
formatter - the formatter to use, null means use toString().Copyright © 2010 - 2023 Adobe. All Rights Reserved