net.fortuna.ical4j.model
Class Dur

java.lang.Object
  extended bynet.fortuna.ical4j.model.Dur
All Implemented Interfaces:
Comparable, Serializable

public class Dur
extends Object
implements Comparable, Serializable

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"
 

Author:
Ben Fortuna
See Also:
Serialized Form

Constructor Summary
Dur(Date start, Date end)
          Constructs a new duration representing the time between the two specified dates.
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(String value)
          Constructs a new duration instance from a string representation.
 
Method Summary
 int compareTo(Dur arg0)
          Compares this duration with another.
 int compareTo(Object arg0)
           
 int getDays()
           
 int getHours()
           
 int getMinutes()
           
 int getSeconds()
           
 Date getTime(Date start)
          Returns a date representing the end of this duration from the specified start date.
 int getWeeks()
           
 boolean isNegative()
           
 Dur negate()
          Provides a negation of this instance.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Dur

public Dur(String value)
Constructs a new duration instance from a string representation.

Parameters:
value - a string representation of a duration

Dur

public Dur(int weeks)
Constructs a new duration from the specified weeks.

Parameters:
weeks - a duration in weeks.

Dur

public Dur(int days,
           int hours,
           int minutes,
           int seconds)
Constructs a new duration from the specified arguments.

Parameters:
days - duration in days
hours - duration in hours
minutes - duration in minutes
seconds - duration in seconds

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.

Parameters:
start - the start date of the duration
end - the end date of the duration
Method Detail

getTime

public final Date getTime(Date start)
Returns a date representing the end of this duration from the specified start date.

Parameters:
start - the date to start the duration
Returns:
the end of the duration as a date

negate

public final Dur negate()
Provides a negation of this instance.

Returns:
a Dur instance that represents a negation of this instance

toString

public final String toString()

compareTo

public final int compareTo(Object arg0)
Specified by:
compareTo in interface Comparable
Parameters:
arg0 -
Returns:

compareTo

public final int compareTo(Dur arg0)
Compares this duration with another.

Parameters:
arg0 -
Returns:

getDays

public final int getDays()
Returns:
Returns the days.

getHours

public final int getHours()
Returns:
Returns the hours.

getMinutes

public final int getMinutes()
Returns:
Returns the minutes.

isNegative

public final boolean isNegative()
Returns:
Returns the negative.

getSeconds

public final int getSeconds()
Returns:
Returns the seconds.

getWeeks

public final int getWeeks()
Returns:
Returns the weeks.