|
Joda Time API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
Readable interface for an instant in the datetime continuum.
This interface expresses the datetime as milliseconds from 1970-01-01T00:00:00Z.
| Method Summary | |
int |
compareTo(java.lang.Object readableInstant)
Compares this object with the specified object for ascending millisecond instant order. |
boolean |
equals(java.lang.Object readableInstant)
Compares this object with the specified object for equality based on the millisecond instant and the Chronology. |
int |
get(DateTimeField field)
Get the value of one of the fields of a datetime. |
Chronology |
getChronology()
Gets the chronology of the instant, null if not applicable. |
DateTimeZone |
getDateTimeZone()
Gets the time zone of the instant, null if not applicable. |
long |
getMillis()
Get the value as the number of miliseconds since the epoch, 1970-01-01T00:00:00Z. |
int |
hashCode()
Gets a hash code for the instant that is compatable with the equals method. |
boolean |
isAfter(ReadableInstant readableInstant)
Is the millisecond value after the millisecond passed in. |
boolean |
isBefore(ReadableInstant readableInstant)
Is the millisecond value before the millisecond passed in. |
boolean |
isEqual(ReadableInstant readableInstant)
Is the millisecond value equal to the millisecond passed in. |
ReadableInstant |
toCopy(Chronology newChronology)
Gets a copy of this instant with a different chronology. |
ReadableInstant |
toCopy(long newMillis)
Gets a copy of this instant with different millis. |
Instant |
toInstant()
Get the value as a simple immutable Instant object. |
java.lang.String |
toString()
Get the value as a String in a recognisable ISO8601 format. |
| Method Detail |
public long getMillis()
public Chronology getChronology()
The Chronology provides conversion from the millisecond
value to meaningful fields in a particular calendar system.
public DateTimeZone getDateTimeZone()
public int get(DateTimeField field)
DateTimeField instances are generally obtained from a Chronology subclass.
However, an application can create its own DateTimeField to manipulate the
date time millis in new ways.
field - a DateTimeField instance, usually obtained from a Chronology
java.lang.IllegalArgumentException - if the field is nullpublic ReadableInstant toCopy(long newMillis)
The returned object will be a new instance of the same implementation type.
Only the millis will change, the chronology and time zone are kept.
Immutable subclasses may return this if appropriate.
newMillis - the new millis, from 1970-01-01T00:00:00Z
public ReadableInstant toCopy(Chronology newChronology)
The returned object will be a new instance of the same implementation type.
Only the chronology will change, the millis are kept.
Immutable subclasses may return this if appropriate.
newChronology - the new chronology
java.lang.IllegalArgumentException - if the chronology is nullpublic Instant toInstant()
Instant object.
This can be useful if you don't trust the implementation of the interface to be well-behaved, or to get a guaranteed immutable object.
Instant objectpublic boolean equals(java.lang.Object readableInstant)
To compare two instants for absolute time (ie. UTC milliseconds
ignoring the chronology), use isEqual(ReadableInstant) or
compareTo(Object).
equals in class java.lang.ObjectreadableInstant - a readable instant to check against
public int hashCode()
The formula used must be as follows:
int result = 317; result = 59 * result + ((int) (getMillis() ^ (getMillis() >>> 32))); result = 59 * result + (getChronology() == null ? 0 : getChronology().hashCode()); return result;
hashCode in class java.lang.Objectpublic int compareTo(java.lang.Object readableInstant)
All ReadableInstant instances are accepted.
compareTo in interface java.lang.ComparablereadableInstant - a readable instant to check against
java.lang.NullPointerException - if the object is null
java.lang.ClassCastException - if the object type is not supportedpublic boolean isAfter(ReadableInstant readableInstant)
readableInstant - an instant to check against
java.lang.IllegalArgumentException - if the instant is nullpublic boolean isBefore(ReadableInstant readableInstant)
readableInstant - an instant to check against
java.lang.IllegalArgumentException - if the instant is nullpublic boolean isEqual(ReadableInstant readableInstant)
readableInstant - an instant to check against
java.lang.IllegalArgumentException - if the instant is nullpublic java.lang.String toString()
The string output is in ISO8601 format to enable the String constructor to correctly parse it.
toString in class java.lang.Object
|
Joda Time API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||