org.joda.time
Interface ReadablePartial
- AbstractPartial, BaseLocal, BasePartial, LocalDate, LocalDateTime, LocalTime, Partial, TimeOfDay, YearMonthDay
public interface ReadablePartial
Defines a partial time that does not support every datetime field, and is
thus a local time.
A
ReadablePartial
supports a subset of those fields on the chronology.
It cannot be compared to a
ReadableInstant
, as it does not fully
specify an instant in time. The time it does specify is a local time, and does
not include a time zone.
A
ReadablePartial
can be converted to a
ReadableInstant
using the
toDateTime
method. This works by providing a full base
instant that can be used to 'fill in the gaps' and specify a time zone.
boolean | equals(Object partial) - Compares this partial with the specified object for equality based
on the supported fields, chronology and values.
|
int | get(DateTimeFieldType field) - Gets the value of one of the fields.
|
Chronology | getChronology() - Gets the chronology of the partial which is never null.
|
DateTimeField | getField(int index) - Gets the field at the specified index.
|
DateTimeFieldType | getFieldType(int index) - Gets the field type at the specified index.
|
int | getValue(int index) - Gets the value at the specified index.
|
int | hashCode() - Gets a hash code for the partial that is compatible with the
equals method.
|
boolean | isSupported(DateTimeFieldType field) - Checks whether the field type specified is supported by this partial.
|
int | size() - Gets the number of fields that this partial supports.
|
DateTime | toDateTime(ReadableInstant baseInstant) - Converts this partial to a full datetime by resolving it against another
datetime.
|
String | toString() - Get the value as a String in a recognisable ISO8601 format, only
displaying supported fields.
|
equals
public boolean equals(Object partial)
Compares this partial with the specified object for equality based
on the supported fields, chronology and values.
Two instances of ReadablePartial are equal if they have the same
chronology, same field types (in same order) and same values.
partial
- the object to compare to
get
public int get(DateTimeFieldType field)
Gets the value of one of the fields.
The field type specified must be one of those that is supported by the partial.
field
- a DateTimeFieldType instance that is supported by this partial
getChronology
public Chronology getChronology()
Gets the chronology of the partial which is never null.
The
Chronology
is the calculation engine behind the partial and
provides conversion and validation of the fields in a particular calendar system.
- the chronology, never null
getField
public DateTimeField getField(int index)
Gets the field at the specified index.
index
- the index to retrieve
- the field at the specified index
getFieldType
public DateTimeFieldType getFieldType(int index)
Gets the field type at the specified index.
index
- the index to retrieve
- the field at the specified index
getValue
public int getValue(int index)
Gets the value at the specified index.
index
- the index to retrieve
- the value of the field at the specified index
hashCode
public int hashCode()
Gets a hash code for the partial that is compatible with the
equals method.
The formula used must be:
int total = 157;
for (int i = 0; i <32fields.length; i++) {
total = 23 * total + values[i];
total = 23 * total + fieldTypes[i].hashCode();
}
total += chronology.hashCode();
return total;
isSupported
public boolean isSupported(DateTimeFieldType field)
Checks whether the field type specified is supported by this partial.
field
- the field to check, may be null which returns false
- true if the field is supported
size
public int size()
Gets the number of fields that this partial supports.
- the number of fields supported
toDateTime
public DateTime toDateTime(ReadableInstant baseInstant)
Converts this partial to a full datetime by resolving it against another
datetime.
This method takes the specified datetime and sets the fields from this
instant on top. The chronology from the base instant is used.
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.
baseInstant
- the instant that provides the missing fields, null means now
toString
public String toString()
Get the value as a String in a recognisable ISO8601 format, only
displaying supported fields.
The string output is in ISO8601 format to enable the String
constructor to correctly parse it.
- the value as an ISO8601 string
Copyright (c) 2001-2006 - Joda.org