Package org.joda.time.base
Class BaseInterval
java.lang.Object
org.joda.time.base.AbstractInterval
org.joda.time.base.BaseInterval
- All Implemented Interfaces:
Serializable
,ReadableInterval
- Direct Known Subclasses:
Interval
,MutableInterval
public abstract class BaseInterval
extends AbstractInterval
implements ReadableInterval, Serializable
BaseInterval is an abstract implementation of ReadableInterval that stores
data in two
long
millisecond fields.
This class should generally not be used directly by API users.
The ReadableInterval
interface should be used when different
kinds of interval objects are to be referenced.
BaseInterval subclasses may be mutable and not thread-safe.
- Since:
- 1.0
- Author:
- Brian S O'Neill, Sean Geoghegan, Stephen Colebourne
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
BaseInterval
(long startInstant, long endInstant, Chronology chrono) Constructs an interval from a start and end instant.protected
BaseInterval
(Object interval, Chronology chrono) Constructs a time interval converting or copying from another object that describes an interval.protected
BaseInterval
(ReadableDuration duration, ReadableInstant end) Constructs an interval from a millisecond duration and an end instant.protected
BaseInterval
(ReadableInstant start, ReadableDuration duration) Constructs an interval from a start instant and a duration.protected
BaseInterval
(ReadableInstant start, ReadableInstant end) Constructs an interval from a start and end instant.protected
BaseInterval
(ReadableInstant start, ReadablePeriod period) Constructs an interval from a start instant and a time period.protected
BaseInterval
(ReadablePeriod period, ReadableInstant end) Constructs an interval from a time period and an end instant. -
Method Summary
Modifier and TypeMethodDescriptionGets the chronology of this interval.long
Gets the end of this time interval which is exclusive.long
Gets the start of this time interval which is inclusive.protected void
setInterval
(long startInstant, long endInstant, Chronology chrono) Sets this interval from two millisecond instants and a chronology.Methods inherited from class org.joda.time.base.AbstractInterval
checkInterval, contains, contains, contains, containsNow, equals, getEnd, getStart, hashCode, isAfter, isAfter, isAfter, isAfterNow, isBefore, isBefore, isBefore, isBeforeNow, isEqual, overlaps, toDuration, toDurationMillis, toInterval, toMutableInterval, toPeriod, toPeriod, toString
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.joda.time.ReadableInterval
contains, contains, equals, getEnd, getStart, hashCode, isAfter, isAfter, isBefore, isBefore, overlaps, toDuration, toDurationMillis, toInterval, toMutableInterval, toPeriod, toPeriod, toString
-
Constructor Details
-
BaseInterval
Constructs an interval from a start and end instant.- Parameters:
startInstant
- start of this interval, as milliseconds from 1970-01-01T00:00:00Z.endInstant
- end of this interval, as milliseconds from 1970-01-01T00:00:00Z.chrono
- the chronology to use, null is ISO default- Throws:
IllegalArgumentException
- if the end is before the start
-
BaseInterval
Constructs an interval from a start and end instant.- Parameters:
start
- start of this interval, null means nowend
- end of this interval, null means now- Throws:
IllegalArgumentException
- if the end is before the start
-
BaseInterval
Constructs an interval from a start instant and a duration.- Parameters:
start
- start of this interval, null means nowduration
- the duration of this interval, null means zero length- Throws:
IllegalArgumentException
- if the end is before the startArithmeticException
- if the end instant exceeds the capacity of a long
-
BaseInterval
Constructs an interval from a millisecond duration and an end instant.- Parameters:
duration
- the duration of this interval, null means zero lengthend
- end of this interval, null means now- Throws:
IllegalArgumentException
- if the end is before the startArithmeticException
- if the start instant exceeds the capacity of a long
-
BaseInterval
Constructs an interval from a start instant and a time period.When forming the interval, the chronology from the instant is used if present, otherwise the chronology of the period is used.
- Parameters:
start
- start of this interval, null means nowperiod
- the period of this interval, null means zero length- Throws:
IllegalArgumentException
- if the end is before the startArithmeticException
- if the end instant exceeds the capacity of a long
-
BaseInterval
Constructs an interval from a time period and an end instant.When forming the interval, the chronology from the instant is used if present, otherwise the chronology of the period is used.
- Parameters:
period
- the period of this interval, null means zero lengthend
- end of this interval, null means now- Throws:
IllegalArgumentException
- if the end is before the startArithmeticException
- if the start instant exceeds the capacity of a long
-
BaseInterval
Constructs a time interval converting or copying from another object that describes an interval.- Parameters:
interval
- the time interval to copychrono
- the chronology to use, null means let converter decide- Throws:
IllegalArgumentException
- if the interval is invalid
-
-
Method Details
-
getChronology
Gets the chronology of this interval.- Specified by:
getChronology
in interfaceReadableInterval
- Returns:
- the chronology
-
getStartMillis
public long getStartMillis()Gets the start of this time interval which is inclusive.- Specified by:
getStartMillis
in interfaceReadableInterval
- Returns:
- the start of the time interval, millisecond instant from 1970-01-01T00:00:00Z
-
getEndMillis
public long getEndMillis()Gets the end of this time interval which is exclusive.- Specified by:
getEndMillis
in interfaceReadableInterval
- Returns:
- the end of the time interval, millisecond instant from 1970-01-01T00:00:00Z
-
setInterval
Sets this interval from two millisecond instants and a chronology.- Parameters:
startInstant
- the start of the time intervalendInstant
- the start of the time intervalchrono
- the chronology, not null- Throws:
IllegalArgumentException
- if the end is before the start
-