net.fortuna.ical4j.model
Class Dur
java.lang.Object
net.fortuna.ical4j.model.Dur
- Comparable, Serializable
public class Dur
extends java.lang.Object
implements Comparable, Serializable
$Id: Dur.java,v 1.19 2008/12/16 12:34:52 fortuna Exp $
Created on 20/06/2005
Represents a duration of time in iCalendar. Note that according to RFC2445 durations represented in weeks are
mutually exclusive of other duration fields.
4.3.6 Duration
Value Name: DURATION
Purpose: This value type is used to identify properties that contain
a duration of time.
Formal Definition: The value type is defined by the following
notation:
dur-value = (["+"] / "-") "P" (dur-date / dur-time / dur-week)
dur-date = dur-day [dur-time]
dur-time = "T" (dur-hour / dur-minute / dur-second)
dur-week = 1*DIGIT "W"
dur-hour = 1*DIGIT "H" [dur-minute]
dur-minute = 1*DIGIT "M" [dur-second]
dur-second = 1*DIGIT "S"
dur-day = 1*DIGIT "D"
Dur(Date start, Date end) - Constructs a new duration representing the time between the two specified dates.
|
Dur(String value) - Constructs a new duration instance from a string representation.
|
Dur(int weeks) - Constructs a new duration from the specified weeks.
|
Dur(int days, int hours, int minutes, int seconds) - Constructs a new duration from the specified arguments.
|
Dur
public Dur(Date start,
Date end)
Constructs a new duration representing the time between the two specified dates. The end date may precede the
start date in order to represent a negative duration.
start
- the start date of the durationend
- the end date of the duration
Dur
public Dur(String value)
Constructs a new duration instance from a string representation.
value
- a string representation of a duration
Dur
public Dur(int weeks)
Constructs a new duration from the specified weeks.
weeks
- a duration in weeks.
Dur
public Dur(int days,
int hours,
int minutes,
int seconds)
Constructs a new duration from the specified arguments.
days
- duration in dayshours
- duration in hoursminutes
- duration in minutesseconds
- duration in seconds
add
public final Dur add(Dur duration)
Add two durations. Durations may only be added if they are both positive
or both negative durations.
duration
- the duration to add to this duration
- a new instance representing the sum of the two durations.
compareTo
public final int compareTo(Dur arg0)
Compares this duration with another, acording to their length.
compareTo
public final int compareTo(Object arg0)
Compares the durations' lengths.
equals
public boolean equals(Object obj)
getDays
public final int getDays()
getHours
public final int getHours()
getMinutes
public final int getMinutes()
getSeconds
public final int getSeconds()
getTime
public final Date getTime(Date start)
Returns a date representing the end of this duration from the specified start date.
start
- the date to start the duration
- the end of the duration as a date
getWeeks
public final int getWeeks()
hashCode
public int hashCode()
isNegative
public final boolean isNegative()
negate
public final Dur negate()
Provides a negation of this instance.
- a Dur instance that represents a negation of this instance
toString
public final String toString()