Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.joda.time
Class MutableInterval  view MutableInterval download MutableInterval.java

java.lang.Object
  extended byorg.joda.time.base.AbstractInterval
      extended byorg.joda.time.base.BaseInterval
          extended byorg.joda.time.MutableInterval
All Implemented Interfaces:
java.lang.Cloneable, ReadableInterval, ReadWritableInterval, java.io.Serializable

public class MutableInterval
extends org.joda.time.base.BaseInterval
implements ReadWritableInterval, java.lang.Cloneable, java.io.Serializable

MutableInterval is the standard implementation of a mutable time interval.

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.

If performing significant calculations on an interval, it may be faster to convert an Interval object to a MutableInterval one.

MutableInterval is mutable and not thread-safe, unless concurrent threads are not invoking mutator methods.

Since:
1.0

Field Summary
private static long serialVersionUID
          Serialization version
 
Fields inherited from class org.joda.time.base.BaseInterval
 
Constructor Summary
MutableInterval()
          Constructs a zero length time interval from 1970-01-01 to 1970-01-01.
MutableInterval(long startInstant, long endInstant)
          Constructs an interval from a start and end instant with the ISO default chronology.
MutableInterval(long startInstant, long endInstant, Chronology chronology)
          Constructs an interval from a start and end instant with a chronology.
MutableInterval(java.lang.Object interval)
          Constructs a time interval by converting or copying from another object.
MutableInterval(java.lang.Object interval, Chronology chronology)
          Constructs a time interval by converting or copying from another object, overriding the chronology.
MutableInterval(ReadableDuration duration, ReadableInstant end)
          Constructs an interval from a millisecond duration and an end instant.
MutableInterval(ReadableInstant start, ReadableDuration duration)
          Constructs an interval from a start instant and a duration.
MutableInterval(ReadableInstant start, ReadableInstant end)
          Constructs an interval from a start and end instant.
MutableInterval(ReadableInstant start, ReadablePeriod period)
          Constructs an interval from a start instant and a time period.
MutableInterval(ReadablePeriod period, ReadableInstant end)
          Constructs an interval from a time period and an end instant.
 
Method Summary
 java.lang.Object clone()
          Clone this object.
 MutableInterval copy()
          Clone this object without having to cast the returned object.
 void setChronology(Chronology chrono)
          Sets the chronology of this time interval.
 void setDurationAfterStart(long duration)
          Sets the duration of this time interval, preserving the start instant.
 void setDurationAfterStart(ReadableDuration duration)
          Sets the duration of this time interval, preserving the start instant.
 void setDurationBeforeEnd(long duration)
          Sets the duration of this time interval, preserving the end instant.
 void setDurationBeforeEnd(ReadableDuration duration)
          Sets the duration of this time interval, preserving the end instant.
 void setEnd(ReadableInstant end)
          Sets the end of this time interval as an Instant.
 void setEndMillis(long endInstant)
          Sets the end of this time interval.
 void setInterval(long startInstant, long endInstant)
          Sets this interval from two millisecond instants retaining the chronology.
 void setInterval(ReadableInstant start, ReadableInstant end)
          Sets this interval from two instants, replacing the chronology with that from the start instant.
 void setInterval(ReadableInterval interval)
          Sets this interval to be the same as another.
 void setPeriodAfterStart(ReadablePeriod period)
          Sets the period of this time interval, preserving the start instant and using the ISOChronology in the default zone for calculations.
 void setPeriodBeforeEnd(ReadablePeriod period)
          Sets the period of this time interval, preserving the end instant and using the ISOChronology in the default zone for calculations.
 void setStart(ReadableInstant start)
          Sets the start of this time interval as an Instant.
 void setStartMillis(long startInstant)
          Sets the start of this time interval.
 
Methods inherited from class org.joda.time.base.BaseInterval
getChronology, getEndMillis, getStartMillis, setInterval
 
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, overlaps, toDuration, toDurationMillis, toInterval, toMutableInterval, toPeriod, toPeriod, toString
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.joda.time.ReadableInterval
contains, contains, equals, getChronology, getEnd, getEndMillis, getStart, getStartMillis, hashCode, isAfter, isAfter, isBefore, isBefore, overlaps, toDuration, toDurationMillis, toInterval, toMutableInterval, toPeriod, toPeriod, toString
 

Field Detail

serialVersionUID

private static final long serialVersionUID
Serialization version

See Also:
Constant Field Values
Constructor Detail

MutableInterval

public MutableInterval()
Constructs a zero length time interval from 1970-01-01 to 1970-01-01.


MutableInterval

public MutableInterval(long startInstant,
                       long endInstant)
Constructs an interval from a start and end instant with the ISO default chronology.


MutableInterval

public MutableInterval(long startInstant,
                       long endInstant,
                       Chronology chronology)
Constructs an interval from a start and end instant with a chronology.


MutableInterval

public MutableInterval(ReadableInstant start,
                       ReadableInstant end)
Constructs an interval from a start and end instant.

The chronology used is that of the start instant.


MutableInterval

public MutableInterval(ReadableInstant start,
                       ReadableDuration duration)
Constructs an interval from a start instant and a duration.


MutableInterval

public MutableInterval(ReadableDuration duration,
                       ReadableInstant end)
Constructs an interval from a millisecond duration and an end instant.


MutableInterval

public MutableInterval(ReadableInstant start,
                       ReadablePeriod period)
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.


MutableInterval

public MutableInterval(ReadablePeriod period,
                       ReadableInstant end)
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.


MutableInterval

public MutableInterval(java.lang.Object interval)
Constructs a time interval by converting or copying from another object.


MutableInterval

public MutableInterval(java.lang.Object interval,
                       Chronology chronology)
Constructs a time interval by converting or copying from another object, overriding the chronology.

Method Detail

setInterval

public void setInterval(long startInstant,
                        long endInstant)
Sets this interval from two millisecond instants retaining the chronology.

Specified by:
setInterval in interface ReadWritableInterval

setInterval

public void setInterval(ReadableInterval interval)
Sets this interval to be the same as another.

Specified by:
setInterval in interface ReadWritableInterval

setInterval

public void setInterval(ReadableInstant start,
                        ReadableInstant end)
Sets this interval from two instants, replacing the chronology with that from the start instant.

Specified by:
setInterval in interface ReadWritableInterval

setChronology

public void setChronology(Chronology chrono)
Sets the chronology of this time interval.

Specified by:
setChronology in interface ReadWritableInterval

setStartMillis

public void setStartMillis(long startInstant)
Sets the start of this time interval.

Specified by:
setStartMillis in interface ReadWritableInterval

setStart

public void setStart(ReadableInstant start)
Sets the start of this time interval as an Instant.

Specified by:
setStart in interface ReadWritableInterval

setEndMillis

public void setEndMillis(long endInstant)
Sets the end of this time interval.

Specified by:
setEndMillis in interface ReadWritableInterval

setEnd

public void setEnd(ReadableInstant end)
Sets the end of this time interval as an Instant.

Specified by:
setEnd in interface ReadWritableInterval

setDurationAfterStart

public void setDurationAfterStart(long duration)
Sets the duration of this time interval, preserving the start instant.


setDurationBeforeEnd

public void setDurationBeforeEnd(long duration)
Sets the duration of this time interval, preserving the end instant.


setDurationAfterStart

public void setDurationAfterStart(ReadableDuration duration)
Sets the duration of this time interval, preserving the start instant.

Specified by:
setDurationAfterStart in interface ReadWritableInterval

setDurationBeforeEnd

public void setDurationBeforeEnd(ReadableDuration duration)
Sets the duration of this time interval, preserving the end instant.

Specified by:
setDurationBeforeEnd in interface ReadWritableInterval

setPeriodAfterStart

public void setPeriodAfterStart(ReadablePeriod period)
Sets the period of this time interval, preserving the start instant and using the ISOChronology in the default zone for calculations.

Specified by:
setPeriodAfterStart in interface ReadWritableInterval

setPeriodBeforeEnd

public void setPeriodBeforeEnd(ReadablePeriod period)
Sets the period of this time interval, preserving the end instant and using the ISOChronology in the default zone for calculations.

Specified by:
setPeriodBeforeEnd in interface ReadWritableInterval

copy

public MutableInterval copy()
Clone this object without having to cast the returned object.


clone

public java.lang.Object clone()
Clone this object.