net.sf.mpxj
Class Duration

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

public final class Duration
extends Object
implements 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, double daysPerMonth)
          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(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()
          
 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,
                                    double daysPerMonth)
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
daysPerMonth - number of days per month
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(Object o)

Overrides:
equals in class Object

hashCode

public int hashCode()

Overrides:
hashCode in class Object

compareTo

public int compareTo(Duration rhs)

Specified by:
compareTo in interface Comparable<Duration>

toString

public String toString()

Overrides:
toString in class Object


Copyright © 2012. All Rights Reserved.