MPXJ: Microsoft Project Exchange

net.sf.mpxj
Class Duration

Package class diagram package Duration
java.lang.Object
  extended by net.sf.mpxj.Duration
All Implemented Interfaces:
java.lang.Comparable<Duration>

public final class Duration
extends java.lang.Object
implements java.lang.Comparable<Duration>

This represents time durations as specified in an MPX file.


Method Summary
 int compareTo(Duration rhs)
          
static Duration convertUnits(double duration, TimeUnit fromUnits, TimeUnit toUnits, double minutesPerDay, double minutesPerWeek)
          This method provides an approximate conversion between duration units.
static Duration convertUnits(double duration, TimeUnit fromUnits, TimeUnit toUnits, ProjectHeader defaults)
          This method provides an approximate conversion between duration units.
 Duration convertUnits(TimeUnit type, ProjectHeader defaults)
          This method provides an approximate conversion between duration units.
 boolean equals(java.lang.Object o)
          
 double getDuration()
          This method is used to retrieve the size of the duration.
static Duration getInstance(double duration, TimeUnit type)
          Retrieve an Duration instance.
static Duration getInstance(int duration, TimeUnit type)
          Retrieve an Duration instance.
 TimeUnit getUnits()
          This method is used to retrieve the type of units the duration is expressed in.
 int hashCode()
          
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getDuration

public double getDuration()
This method is used to retrieve the size of the duration.

Returns:
size of the duration

getUnits

public TimeUnit getUnits()
This method is used to retrieve the type of units the duration is expressed in. The valid types of units are found in the TimeUnit class.

Returns:
type of units

convertUnits

public Duration convertUnits(TimeUnit type,
                             ProjectHeader defaults)
This method provides an approximate conversion between duration units. It does take into account the project defaults for number of hours in a day and a week, but it does not take account of calendar details. The results obtained from it should therefore be treated with caution.

Parameters:
type - target duration type
defaults - project header containing default values
Returns:
new Duration instance

convertUnits

public static Duration convertUnits(double duration,
                                    TimeUnit fromUnits,
                                    TimeUnit toUnits,
                                    ProjectHeader defaults)
This method provides an approximate conversion between duration units. It does take into account the project defaults for number of hours in a day and a week, but it does not take account of calendar details. The results obtained from it should therefore be treated with caution.

Parameters:
duration - duration value
fromUnits - units to convert from
toUnits - units to convert to
defaults - project header containing default values
Returns:
new Duration instance

convertUnits

public static Duration convertUnits(double duration,
                                    TimeUnit fromUnits,
                                    TimeUnit toUnits,
                                    double minutesPerDay,
                                    double minutesPerWeek)
This method provides an approximate conversion between duration units. It does take into account the project defaults for number of hours in a day and a week, but it does not take account of calendar details. The results obtained from it should therefore be treated with caution.

Parameters:
duration - duration value
fromUnits - units to convert from
toUnits - units to convert to
minutesPerDay - number of minutes per day
minutesPerWeek - number of minutes per week
Returns:
new Duration instance

getInstance

public static Duration getInstance(double duration,
                                   TimeUnit type)
Retrieve an Duration instance. Use shared objects to represent common values for memory efficiency.

Parameters:
duration - duration value
type - duration type
Returns:
Duration instance

getInstance

public static Duration getInstance(int duration,
                                   TimeUnit type)
Retrieve an Duration instance. Use shared objects to represent common values for memory efficiency.

Parameters:
duration - duration value
type - duration type
Returns:
Duration instance

equals

public boolean equals(java.lang.Object o)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(Duration rhs)

Specified by:
compareTo in interface java.lang.Comparable<Duration>

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object


Copyright © 2000-2009 Packwood Software. All Rights Reserved.