Nitido Inc.

com.nitido.nimx.nuggets.wcap
Class Duration

java.lang.Object
  extended by com.nitido.nimx.nuggets.wcap.Duration

public class Duration
extends java.lang.Object

Duration class convert different time format into int fields of the week, day, hour, min, and sec. The time input are specified as parameters to the special purpose constructors. The time units can be retrieved directly from the public fields once the object has been instantiated successfully.

The first special purpose constructor takes in an ISO 8601 duration format String and break it down into the different time units. (e.g. P1DT2H30M = 1 day, 2 hours and 30 minutes ) NOTE: According to RFC 2445, calendar server doesn't need to support the year and month field of the ISO 8601 duration string. Therefore, this class does not provide these two fields.

The second special purpose constructor takes in the start and end Date objects and compute the duration fields based on the differences of thes two objects.


Field Summary
 int day
          The number of days in the duration.
 int hour
          The number of hours in the duration.
 boolean isPositive
          The boolean flag to indicate if the duration is a regular positive duration.
 int min
          The number of minutes in the duration.
 int sec
          The number of seconds in the duration.
 int week
          The number of weeks in the duration.
 
Constructor Summary
Duration(boolean isPositive, int week, int day, int hour, int min, int sec)
          Default constructor.
Duration(java.util.Date startTime, java.util.Date endTime)
          DateTime difference constructor.
Duration(int hour, int min)
          Convenience constructor.
Duration(int week, int day, int hour, int min, int sec)
          Event/ToDo specific duration constructor.
Duration(java.lang.String durString)
          ISO String constructor.
 
Method Summary
 boolean equals(java.lang.Object inObj)
          Override the default java.lang.Object's equal command.
 java.util.Date toEndTime(java.util.Date startTime)
          Return an end Date object based on the startTime parameter.
 java.lang.String toString()
          Return an ISO 8601 duration format representation of the duration time information.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

isPositive

public boolean isPositive
The boolean flag to indicate if the duration is a regular positive duration. A positive duration indicates the end time is "after" the start time.

It can be false if the duration is specifying the end time is "before" the start time (i.e. when it is a negative duration). The default value is true.


week

public int week
The number of weeks in the duration.

A valid value must be a postive integer. 0 or negative number means this field is not set.


day

public int day
The number of days in the duration.

A valid value must be a postive integer. 0 or negative number means this field is not set.


hour

public int hour
The number of hours in the duration.

A valid value must be a postive integer. 0 or negative number means this field is not set.


min

public int min
The number of minutes in the duration.

A valid value must be a postive integer. 0 or negative number means this field is not set.


sec

public int sec
The number of seconds in the duration.

A valid value must be a postive integer. 0 or negative number means this field is not set.

Constructor Detail

Duration

public Duration(boolean isPositive,
                int week,
                int day,
                int hour,
                int min,
                int sec)
Default constructor.

Parameters:
isPositive - The boolean flag to indicate if the duration is a regular positive duration. A positive duration indicates the end time is "after" the start time. This value can be false if the duration is specifying the end time is "before" the start time (i.e. when it is a negative duration). The default value is true.
week - The number of weeks in the duration. A valid value must be a postive integer. 0 or negative number means this field is not set.
day - The number of days in the duration. A valid value must be a postive integer. 0 or negative number means this field is not set.
hour - The number of hours in the duration. A valid value must be a postive integer. 0 or negative number means this field is not set.
min - The number of minutes in the duration. A valid value must be a postive integer. 0 or negative number means this field is not set.
sec - The number of seconds in the duration. A valid value must be a postive integer. 0 or negative number means this field is not set.

Duration

public Duration(int week,
                int day,
                int hour,
                int min,
                int sec)
Event/ToDo specific duration constructor. This constructor is usually invoked by the application to generate the duration field for event/todo. In these situation, the duration object is always positive. Therefore, this constructor doesn't require the isPositive field.

Parameters:
week - The number of weeks in the duration. A valid value must be a postive integer. 0 or negative number means this field is not set.
day - The number of days in the duration. A valid value must be a postive integer. 0 or negative number means this field is not set.
hour - The number of hours in the duration. A valid value must be a postive integer. 0 or negative number means this field is not set.
min - The number of minutes in the duration. A valid value must be a postive integer. 0 or negative number means this field is not set.
sec - The number of seconds in the duration. A valid value must be a postive integer. 0 or negative number means this field is not set.

Duration

public Duration(int hour,
                int min)
Convenience constructor. This constructor is probably used the most frequently in a calendar application, as most of the event/todo/alarm has duration measured in hours and minutes only.

Parameters:
hour - The number of hours in the duration. A valid value must be a postive integer. 0 or negative number means this field is not set.
min - The number of minutess in the duration. A valid value must be a postive integer. 0 or negative number means this field is not set.

Duration

public Duration(java.lang.String durString)
         throws InvalidParameterException
ISO String constructor. Build the object based on a duration string as specified by RFC 2445 and ISO 8601

Parameters:
durString - This parameter should be in the duration format
Throws:
InvalidParameterException

Duration

public Duration(java.util.Date startTime,
                java.util.Date endTime)
DateTime difference constructor. Build the object based on the difference between the start time and end time.

Parameters:
startTime - The starting Date object.
endTime - The ending Date object.
Method Detail

toEndTime

public java.util.Date toEndTime(java.util.Date startTime)
Return an end Date object based on the startTime parameter. (i.e. duration = startTime - endTime ).

Parameters:
startTime - The start Date object.

toString

public java.lang.String toString()
Return an ISO 8601 duration format representation of the duration time information.

Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object inObj)
Override the default java.lang.Object's equal command. This will compares the content of the fields.

Overrides:
equals in class java.lang.Object

Nitido NiM 2.5 Java API

These JavaDoc pages are generated for release/nim_2_5-2.5.44

Copyright © 1999-2009 Nitido Inc.    Proprietary and Confidential.    All Rights Reserved.