Package net.fortuna.ical4j.model
Class Period
java.lang.Object
net.fortuna.ical4j.model.DateRange
net.fortuna.ical4j.model.Period
- All Implemented Interfaces:
Serializable,Comparable<Period>
$Id$ [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.
- See Also:
-
Field Summary
Fields inherited from class net.fortuna.ical4j.model.DateRange
INCLUSIVE_END, INCLUSIVE_START -
Constructor Summary
ConstructorsConstructorDescriptionConstructor.Period(DateTime start, TemporalAmount duration) Constructs a new period with the specified start date and duration.Constructs a new period with the specied start and end date.Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionfinal PeriodCreates a period that encompasses both this period and another one.final intCompares the specified period with this period.final booleanfinal TemporalAmountReturns the duration of this period.final DateTimegetEnd()Returns the end date of this period.final DateTimegetStart()final inthashCode()final booleanDeprecated.final booleanisEmpty()An empty period is one that consumes no time.voidsetComponent(Component component) final voidsetTimeZone(TimeZone timezone) Updates the start and (possible) end times of this period to reflect the specified timezone status.voidsetUtc(boolean utc) Updates the start and (possible) end times of this period to reflect the specified UTC timezone status.final PeriodListCreates a set of periods resulting from the subtraction of the specified period from this one.final StringtoString()Methods inherited from class net.fortuna.ical4j.model.DateRange
adjacent, after, before, contains, getRangeEnd, getRangeStart, includes, includes, intersects
-
Constructor Details
-
Period
Constructor.- Parameters:
aValue- a string representation of a period- Throws:
ParseException- where the specified string is not a valid representation
-
Period
Constructs a new period with the specied start and end date.- Parameters:
start- the start date of the periodend- the end date of the period
-
Period
Deprecated.Constructs a new period with the specified start date and duration.- Parameters:
start- the start date of the periodduration- the duration of the period
-
Period
Constructs a new period with the specified start date and duration.- Parameters:
start- the start date of the periodduration- the duration of the period
-
-
Method Details
-
getDuration
Returns the duration of this period. If an explicit duration is not specified, the duration is derived from the end date.- Returns:
- the duration of this period in milliseconds.
-
getEnd
Returns the end date of this period. If an explicit end date is not specified, the end date is derived from the duration.- Returns:
- the end date of this period.
-
getStart
- Returns:
- Returns the start.
-
includes
Deprecated.useDateRange.includes(Date, int)instead.- Parameters:
date- a date to test for inclusioninclusive- indicates if the start and end of the period are included in the test- Returns:
- true if the specified date occurs within the current period
-
add
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).- Parameters:
period- the period to add to this one- Returns:
- a period
-
subtract
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.- Parameters:
period- a period to subtract from this one- Returns:
- a list containing zero, one or two periods.
-
isEmpty
public final boolean isEmpty()An empty period is one that consumes no time.- Returns:
- true if this period consumes no time, otherwise false
-
setUtc
public void setUtc(boolean utc) Updates the start and (possible) end times of this period to reflect the specified UTC timezone status.- Parameters:
utc- indicates whether the period is in UTC time
-
setTimeZone
Updates the start and (possible) end times of this period to reflect the specified timezone status.- Parameters:
timezone- a timezone for the period
-
toString
-
compareTo
Compares the specified period with this period. First, compare the start dates. If they are the same, compare the end dates.- Specified by:
compareToin interfaceComparable<Period>- Parameters:
arg0- a period to compare with this one- Returns:
- a postive value if this period is greater, negative if the other is greater, or zero if they are equal
-
equals
-
hashCode
public final int hashCode() -
getComponent
-
setComponent
-
DateRange.includes(Date, int)instead.