public class Period
extends java.lang.Object
implements java.io.Serializable, java.lang.Comparable
| Modifier and Type | Field and Description |
|---|---|
static int |
INCLUSIVE_END |
static int |
INCLUSIVE_START |
| Constructor and Description |
|---|
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(java.lang.String aValue)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
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(java.lang.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(java.lang.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(java.util.Date date)
Determines if the specified date occurs within this period (inclusive of
period start and end).
|
boolean |
includes(java.util.Date date,
boolean inclusive)
Deprecated.
use
includes(Date, int) instead. |
boolean |
includes(java.util.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.
|
java.lang.String |
toString() |
public static final int INCLUSIVE_START
public static final int INCLUSIVE_END
public Period(java.lang.String aValue)
throws java.text.ParseException
aValue - a string representation of a periodjava.text.ParseException - where the specified string is not a valid representationpublic Period(DateTime start, DateTime end)
start - the start date of the periodend - the end date of the periodpublic final Dur getDuration()
public final DateTime getEnd()
public final DateTime getStart()
public final boolean includes(java.util.Date date)
date - public final boolean includes(java.util.Date date,
boolean inclusive)
includes(Date, int) instead.date - inclusive - public final boolean includes(java.util.Date date,
int inclusiveMask)
date - the date to be testedinclusive - specifies whether period start and end are included
in the calculationpublic final boolean before(Period period)
period - a period that may or may not start after this period endspublic final boolean after(Period period)
period - a period that may or may not end before this period startspublic final boolean intersects(Period period)
period - a possible intersecting periodpublic final boolean adjacent(Period period)
public final boolean contains(Period period)
period - the period that may be contained by this onepublic final Period add(Period period)
period - the period to add to this onepublic final PeriodList subtract(Period period)
period - public final boolean isEmpty()
public void setUtc(boolean utc)
utc - public final void setTimeZone(TimeZone timezone)
timezone - public final java.lang.String toString()
toString in class java.lang.ObjectObject.toString()public final int compareTo(java.lang.Object arg0)
compareTo in interface java.lang.Comparablepublic final int compareTo(Period arg0)
arg0 - public final boolean equals(java.lang.Object o)
EqualsBuilder to test equality.equals in class java.lang.Objecto - object being compared for equalitypublic final int hashCode()
HashCodeBuilder to build hashcode.hashCode in class java.lang.Object