net.fortuna.ical4j.model
Class Period
java.lang.Object
net.fortuna.ical4j.model.Period
- Comparable, Serializable
public class Period
extends java.lang.Object
implements Serializable, Comparable
$Id: Period.java,v 1.25 2008/12/16 12:34:52 fortuna Exp $ [Apr 14, 2004]
Defines a period of time. A period may be specified as either a start date
and end date, or a start date and duration. NOTE: End dates and durations are
implicitly derived when not explicitly specified. This means that you cannot
rely on the returned values from the getters to deduce whether a period has
an explicit end date or duration.
Period(DateTime start, DateTime end) - Constructs a new period with the specied start and end date.
|
Period(DateTime start, Dur duration) - Constructs a new period with the specified start date and duration.
|
Period(String aValue) - Constructor.
|
Period | add(Period period) - Creates a period that encompasses both this period and another one.
|
boolean | adjacent(Period period) - Decides whether these periods are serial without a gap.
|
boolean | after(Period period) - Decides whether this period starts after the given period ends.
|
boolean | before(Period period) - Decides whether this period is completed before the given period starts.
|
int | compareTo(Object arg0)
|
int | compareTo(Period arg0) - Compares the specified period with this period.
|
boolean | contains(Period period) - Decides whether the given period is completely contained within this one.
|
boolean | equals(Object o) - Uses
EqualsBuilder to test equality.
|
Dur | getDuration() - Returns the duration of this period.
|
DateTime | getEnd() - Returns the end date of this period.
|
DateTime | getStart()
|
int | hashCode() - Uses
HashCodeBuilder to build hashcode.
|
boolean | includes(Date date) - Determines if the specified date occurs within this period (inclusive of
period start and end).
|
boolean | includes(Date date, boolean inclusive) - use
Period.includes(Date, int) instead.
|
boolean | includes(Date date, int inclusiveMask) - Decides whether a date falls within this period.
|
boolean | intersects(Period period) - Decides whether this period intersects with another one.
|
boolean | isEmpty() - An empty period is one that consumes no time.
|
void | setTimeZone(TimeZone timezone) - Updates the start and (possible) end times of this period to reflect
the specified timezone status.
|
void | setUtc(boolean utc) - Updates the start and (possible) end times of this period to reflect
the specified UTC timezone status.
|
PeriodList | subtract(Period period) - Creates a set of periods resulting from the subtraction of the specified
period from this one.
|
String | toString()
|
INCLUSIVE_END
public static final int INCLUSIVE_END
INCLUSIVE_START
public static final int INCLUSIVE_START
Period
public Period(DateTime start,
DateTime end)
Constructs a new period with the specied start and end date.
start
- the start date of the periodend
- the end date of the period
Period
public Period(DateTime start,
Dur duration)
Constructs a new period with the specified start date and duration.
start
- the start date of the periodduration
- the duration of the period
Period
public Period(String aValue)
throws ParseException
Constructor.
aValue
- a string representation of a period
add
public final Period add(Period period)
Creates a period that encompasses both this period and another one. If
the other period is null, return a copy of this period. NOTE: Resulting
periods are specified by explicitly setting a start date and end date
(i.e. durations are implied).
period
- the period to add to this one
adjacent
public final boolean adjacent(Period period)
Decides whether these periods are serial without a gap.
- true if one period immediately follows the other, false otherwise
after
public final boolean after(Period period)
Decides whether this period starts after the given period ends.
period
- a period that may or may not end before this period starts
- true if the specified period end before this periods starts,
otherwise false
before
public final boolean before(Period period)
Decides whether this period is completed before the given period starts.
period
- a period that may or may not start after this period ends
- true if the specified period starts after this periods ends,
otherwise false
compareTo
public final int compareTo(Object arg0)
compareTo
public final int compareTo(Period arg0)
Compares the specified period with this period.
contains
public final boolean contains(Period period)
Decides whether the given period is completely contained within this one.
period
- the period that may be contained by this one
- true if this period covers all the dates of the specified period,
otherwise false
equals
public final boolean equals(Object o)
Uses EqualsBuilder
to test equality.
o
- object being compared for equality
- true if the objects are equal, false otherwise
getDuration
public final Dur getDuration()
Returns the duration of this period. If an explicit duration is not
specified, the duration is derived from the end date.
- the duration of this period in milliseconds.
getEnd
public final DateTime getEnd()
Returns the end date of this period. If an explicit end date is not
specified, the end date is derived from the duration.
- the end date of this period.
getStart
public final DateTime getStart()
hashCode
public final int hashCode()
Uses HashCodeBuilder
to build hashcode.
includes
public final boolean includes(Date date)
Determines if the specified date occurs within this period (inclusive of
period start and end).
- true if the specified date occurs within the current period
includes
public final boolean includes(Date date,
boolean inclusive)
use Period.includes(Date, int)
instead.
includes
public final boolean includes(Date date,
int inclusiveMask)
Decides whether a date falls within this period.
date
- the date to be tested
- true if the date is in the perod, false otherwise
intersects
public final boolean intersects(Period period)
Decides whether this period intersects with another one.
period
- a possible intersecting period
- true if the specified period intersects this one, false
otherwise.
isEmpty
public final boolean isEmpty()
An empty period is one that consumes no time.
- true if this period consumes no time, otherwise false
setTimeZone
public final void setTimeZone(TimeZone timezone)
Updates the start and (possible) end times of this period to reflect
the specified timezone status.
setUtc
public void setUtc(boolean utc)
Updates the start and (possible) end times of this period to reflect
the specified UTC timezone status.
subtract
public final PeriodList subtract(Period period)
Creates a set of periods resulting from the subtraction of the specified
period from this one. If the specified period is completely contained
in this period, the resulting list will contain two periods. Otherwise
it will contain one. If the specified period does not interest this period
a list containing this period is returned. If this period is completely
contained within the specified period an empty period list is returned.
- a list containing zero, one or two periods.
toString
public final String toString()
java.lang.Object.toString()