|
Joda Time API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Object | +--org.joda.time.AbstractInstant
AbstractInstant provides the common behaviour for immutable time classes.
This class has no concept of a chronology, all methods work on the millisecond instant.
This class should generally not be used directly by API users. The
ReadableInstant interface should be used when different
kinds of date/time objects are to be referenced.
| Constructor Summary | |
AbstractInstant()
Constructor. |
|
| Method Summary | |
int |
compareTo(java.lang.Object readableInstant)
Compares this object with the specified object for ascending millisecond instant order. |
protected abstract ReadableInstant |
create(long millis,
Chronology chrono)
Creates a new instance of this class. |
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 the specified field. |
DateTimeZone |
getDateTimeZone()
Gets the time zone of the datetime from the chronology. |
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. |
java.util.Calendar |
toCalendar(java.util.Locale locale)
Get the date time as a java.util.Calendar. |
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. |
java.util.Date |
toDate()
Get the date time as a java.util.Date. |
java.util.GregorianCalendar |
toGregorianCalendar()
Get the date time as a java.util.GregorianCalendar. |
Instant |
toInstant()
Get this object as an Instant. |
abstract java.lang.String |
toString()
Get the value as a String in a recognisable ISO8601 format. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.joda.time.ReadableInstant |
getChronology, getMillis |
| Constructor Detail |
public AbstractInstant()
| Method Detail |
public final DateTimeZone getDateTimeZone()
getDateTimeZone in interface ReadableInstant
protected abstract ReadableInstant create(long millis,
Chronology chrono)
The returned object will be a new instance of the implementation.
Immutable subclasses may return this if appropriate.
millis - the new millis, from 1970-01-01T00:00:00Zchrono - the new chronology
java.lang.IllegalArgumentException - if the chronology is nullpublic final int get(DateTimeField field)
This could be used to get a field using a different Chronology. For example:
Instant dt = new Instant(); int gjYear = dt.get(ISOChronology.getInstance().year());
get in interface ReadableInstantfield - the DateTimeField subclass to use
java.lang.IllegalArgumentException - if the field is nullpublic final ReadableInstant toCopy(long newMillis)
The returned object will be a new instance of DateTime.
Only the millis will change, the chronology and time zone are kept.
If the millis is the same, this will be returned.
toCopy in interface ReadableInstantnewMillis - the new millis, from 1970-01-01T00:00:00Z
public final ReadableInstant toCopy(Chronology newChronology)
The returned object will be a new instance of DateTime.
Only the chronology will change, the millis are kept.
If the chronology is the same, this will be returned.
toCopy in interface ReadableInstantnewChronology - the new chronology
java.lang.IllegalArgumentException - if the chronology is nullpublic final Instant toInstant()
toInstant in interface ReadableInstantpublic final java.util.Date toDate()
java.util.Date.
public final java.util.Calendar toCalendar(java.util.Locale locale)
java.util.Calendar.
The locale is passed in, enabling Calendar to select the correct
localized subclass.
locale - the locale to get the Calendar for
java.lang.IllegalArgumentException - if the locale is nullpublic final java.util.GregorianCalendar toGregorianCalendar()
java.util.GregorianCalendar.
public final boolean equals(java.lang.Object readableInstant)
All ReadableInstant instances are accepted.
See isEqual(ReadableInstant) for an equals method that
ignores the Chronology.
equals in interface ReadableInstantequals in class java.lang.ObjectreadableInstant - a readable instant to check against
public final int hashCode()
hashCode in interface ReadableInstanthashCode in class java.lang.Objectpublic final int compareTo(java.lang.Object readableInstant)
All ReadableInstant instances are accepted.
compareTo in interface ReadableInstantreadableInstant - a readable instant to check against
java.lang.NullPointerException - if the object is null
java.lang.ClassCastException - if the object type is not supportedpublic final boolean isAfter(ReadableInstant readableInstant)
isAfter in interface ReadableInstantreadableInstant - an instant to check against
java.lang.IllegalArgumentException - if the object is nullpublic final boolean isBefore(ReadableInstant readableInstant)
isBefore in interface ReadableInstantreadableInstant - an instant to check against
java.lang.IllegalArgumentException - if the object is nullpublic final boolean isEqual(ReadableInstant readableInstant)
isEqual in interface ReadableInstantreadableInstant - an instant to check against
java.lang.IllegalArgumentException - if the object is nullpublic abstract java.lang.String toString()
The string output is in ISO8601 format to enable the String constructor to correctly parse it.
toString in interface ReadableInstanttoString in class java.lang.Object
|
Joda Time API | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||