public interface ReadableInstant extends Comparable
The implementation of this interface may be mutable or immutable. This interface only gives access to retrieve data, never to change it.
Methods in your application should be defined using ReadableInstant
as a parameter if the method only wants to read the instant without needing to know
the specific datetime fields.
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Object readableInstant)
Compares this object with the specified object for ascending
millisecond instant order.
|
boolean |
equals(Object readableInstant)
Compares this object with the specified object for equality based
on the millisecond instant and the Chronology.
|
int |
get(DateTimeFieldType type)
Get the value of one of the fields of a datetime.
|
Chronology |
getChronology()
Gets the chronology of the instant.
|
long |
getMillis()
Get the value as the number of milliseconds since
the epoch, 1970-01-01T00:00:00Z.
|
DateTimeZone |
getZone()
Gets the time zone of the instant from the chronology.
|
int |
hashCode()
Gets a hash code for the instant that is compatible with the
equals method.
|
boolean |
isAfter(ReadableInstant instant)
Is this instant after the instant passed in
comparing solely by millisecond.
|
boolean |
isBefore(ReadableInstant instant)
Is this instant before the instant passed in
comparing solely by millisecond.
|
boolean |
isEqual(ReadableInstant instant)
Is this instant equal to the instant passed in
comparing solely by millisecond.
|
boolean |
isSupported(DateTimeFieldType field)
Checks whether the field type specified is supported by this implementation.
|
Instant |
toInstant()
Get the value as a simple immutable
Instant object. |
String |
toString()
Get the value as a String in a recognisable ISO8601 format.
|
long getMillis()
Chronology getChronology()
The Chronology
provides conversion from the millisecond
value to meaningful fields in a particular calendar system.
DateTimeZone getZone()
int get(DateTimeFieldType type)
This method uses the chronology of the instant to obtain the value.
type
- a field type, usually obtained from DateTimeFieldType, not nullIllegalArgumentException
- if the field type is nullboolean isSupported(DateTimeFieldType field)
field
- the field type to check, may be null which returns falseInstant 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
objectint compareTo(Object readableInstant)
All ReadableInstant instances are accepted.
compareTo
in interface Comparable
readableInstant
- a readable instant to check againstNullPointerException
- if the object is nullClassCastException
- if the object type is not supportedboolean isEqual(ReadableInstant instant)
instant
- an instant to check against, null means nowboolean isAfter(ReadableInstant instant)
instant
- an instant to check against, null means nowboolean isBefore(ReadableInstant instant)
instant
- an instant to check against, null means nowboolean equals(Object readableInstant)
To compare two instants for absolute time (ie. UTC milliseconds
ignoring the chronology), use isEqual(ReadableInstant)
or
compareTo(Object)
.
int hashCode()
The formula used must be as follows:
((int) (getMillis() ^ (getMillis() >>> 32))) + (getChronology().hashCode())
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.