|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Readable interface for an interval of time between two instants.
A time interval represents a period of time between two instants. Intervals are inclusive of the start instant and exclusive of the end. The end instant is always greater than or equal to the start instant.
Intervals have a fixed millisecond duration.
This is the difference between the start and end instants.
The duration is represented separately by ReadableDuration
.
As a result, intervals are not comparable.
To compare the length of two intervals, you should compare their durations.
An interval can also be converted to a ReadablePeriod
.
This represents the difference between the start and end points in terms of fields
such as years and days.
Methods that are passed an interval as a parameter will treat null
as a zero length interval at the current instant in time.
Method Summary | |
boolean |
contains(ReadableInstant instant)
Does this time interval contain the specified instant. |
boolean |
contains(ReadableInterval interval)
Does this time interval contain the specified time interval completely. |
boolean |
equals(Object readableInterval)
Compares this object with the specified object for equality based on start and end millis plus the chronology. |
Chronology |
getChronology()
Gets the chronology of the interval, which is the chronology of the first datetime. |
DateTime |
getEnd()
Gets the end of this time interval, which is exclusive, as a DateTime. |
long |
getEndMillis()
Gets the end of this time interval which is exclusive. |
DateTime |
getStart()
Gets the start of this time interval, which is inclusive, as a DateTime. |
long |
getStartMillis()
Gets the start of this time interval which is inclusive. |
int |
hashCode()
Gets a hash code for the time interval that is compatable with the equals method. |
boolean |
isAfter(ReadableInstant instant)
Is this time interval after the specified instant. |
boolean |
isAfter(ReadableInterval interval)
Is this time interval entirely after the specified interval. |
boolean |
isBefore(ReadableInstant instant)
Is this time interval before the specified instant. |
boolean |
isBefore(ReadableInterval interval)
Is this time interval entirely before the specified interval. |
boolean |
overlaps(ReadableInterval interval)
Does this time interval overlap the specified time interval. |
Duration |
toDuration()
Gets the millisecond duration of this time interval. |
long |
toDurationMillis()
Gets the millisecond duration of this time interval. |
Interval |
toInterval()
Get this interval as an immutable Interval object. |
MutableInterval |
toMutableInterval()
Get this time interval as a MutableInterval . |
Period |
toPeriod()
Converts the duration of the interval to a period using the standard period type. |
Period |
toPeriod(PeriodType type)
Converts the duration of the interval to a period using the specified period type. |
String |
toString()
Get the value as a String in the ISO8601 interval format. |
Method Detail |
public Chronology getChronology()
public long getStartMillis()
public DateTime getStart()
public long getEndMillis()
public DateTime getEnd()
public boolean contains(ReadableInstant instant)
Intervals are inclusive of the start instant and exclusive of the end.
instant
- the instant, null means now
public boolean contains(ReadableInterval interval)
Intervals are inclusive of the start instant and exclusive of the end.
interval
- the time interval to compare to, null means now
public boolean overlaps(ReadableInterval interval)
The intervals overlap if at least some of the time interval is in common. Intervals are inclusive of the start instant and exclusive of the end.
interval
- the time interval to compare to, null means now
public boolean isAfter(ReadableInstant instant)
Intervals are inclusive of the start instant and exclusive of the end.
instant
- the instant to compare to, null means now
public boolean isAfter(ReadableInterval interval)
Intervals are inclusive of the start instant and exclusive of the end.
interval
- the interval to compare to, null means now
public boolean isBefore(ReadableInstant instant)
Intervals are inclusive of the start instant and exclusive of the end.
instant
- the instant to compare to, null means now
public boolean isBefore(ReadableInterval interval)
Intervals are inclusive of the start instant and exclusive of the end.
interval
- the interval to compare to, null means now
public Interval toInterval()
Interval
object.
This will either typecast this instance, or create a new Interval
.
public MutableInterval toMutableInterval()
MutableInterval
.
This will always return a new MutableInterval
with the same interval.
public Duration toDuration()
ArithmeticException
- if the duration exceeds the capacity of a longpublic long toDurationMillis()
ArithmeticException
- if the duration exceeds the capacity of a longpublic Period toPeriod()
This method should be used to exract the field values describing the difference between the start and end instants.
public Period toPeriod(PeriodType type)
This method should be used to exract the field values describing the difference between the start and end instants.
type
- the requested type of the duration, null means standard
public boolean equals(Object readableInterval)
To compare the duration of two time intervals, use toDuration()
to get the durations and compare those.
readableInterval
- a readable interval to check against
public int hashCode()
The formula used must be as follows:
int result = 97; result = 31 * result + ((int) (getStartMillis() ^ (getStartMillis() >>> 32))); result = 31 * result + ((int) (getEndMillis() ^ (getEndMillis() >>> 32))); result = 31 * result + getChronology().hashCode(); return result;
public String toString()
For example, "2004-06-09T12:30:00.000/2004-07-10T13:30:00.000".
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |