public class Period extends DateRange implements java.lang.Comparable<Period>
INCLUSIVE_END, 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)
Deprecated.
|
Period(DateTime start,
java.time.temporal.TemporalAmount 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.
|
int |
compareTo(Period arg0)
Compares the specified period with this period.
|
boolean |
equals(java.lang.Object o) |
java.time.temporal.TemporalAmount |
getDuration()
Returns the duration of this period.
|
DateTime |
getEnd()
Returns the end date of this period.
|
DateTime |
getStart() |
int |
hashCode() |
boolean |
includes(java.util.Date date,
boolean inclusive)
Deprecated.
use
DateRange.includes(Date, int) instead. |
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() |
adjacent, after, before, contains, getRangeEnd, getRangeStart, includes, includes, intersects
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 period@Deprecated public Period(DateTime start, Dur duration)
start
- the start date of the periodduration
- the duration of the periodpublic Period(DateTime start, java.time.temporal.TemporalAmount duration)
start
- the start date of the periodduration
- the duration of the periodpublic final java.time.temporal.TemporalAmount getDuration()
public final DateTime getEnd()
public final DateTime getStart()
public final boolean includes(java.util.Date date, boolean inclusive)
DateRange.includes(Date, int)
instead.date
- a date to test for inclusioninclusive
- indicates if the start and end of the period are included in the testpublic final Period add(Period period)
period
- the period to add to this onepublic final PeriodList subtract(Period period)
period
- a period to subtract from this onepublic final boolean isEmpty()
public void setUtc(boolean utc)
utc
- indicates whether the period is in UTC timepublic final void setTimeZone(TimeZone timezone)
timezone
- a timezone for the periodpublic final java.lang.String toString()
toString
in class java.lang.Object
public final int compareTo(Period arg0)
compareTo
in interface java.lang.Comparable<Period>
arg0
- a period to compare with this one