com.catcode.odf
Class Duration

Object
  extended byDuration

public class Duration
extends Object

Creates an XML-Schema-style Duration object.

Version:
0.1, 2005-10-24
Author:
J. David Eisenberg

Field Summary
protected  int days
           
protected  int hours
           
protected  int minutes
           
protected  int months
           
protected  boolean negative
           
protected  double seconds
           
protected  int years
           
 
Constructor Summary
Duration()
          Create a new Duration with all fields set to zero.
Duration(int years, int months, int days)
          Create a new Duration with years, months and days set as specified.
Duration(int years, int months, int days, int hours, int minutes, double seconds)
          Create a new Duration with all numeric fields set as specified.
 
Method Summary
 int getDays()
          Returns the number of years of this Duration.
 int getHours()
          Returns the number of years of this Duration.
 int getMinutes()
          Returns the number of years of this Duration.
 int getMonths()
          Returns the number of years of this Duration.
 double getSeconds()
          Returns the number of years of this Duration.
 int getYears()
          Returns the number of years of this Duration.
 boolean isNegative()
          Returns the negative status Duration.
static Duration parseDuration(String str)
          Parses the string argument as a Duration.
 void setDays(int days)
          Sets the number of days of this Duration to the specified value.
 void setHours(int hours)
          Sets the number of hours of this Duration to the specified value.
 void setMinutes(int minutes)
          Sets the number of minutes of this Duration to the specified value.
 void setMonths(int months)
          Sets the number of months of this Duration to the specified value.
 void setNegative(boolean negative)
          Sets the negative status of this Duration to the specified value.
 void setSeconds(double seconds)
          Sets the number of seconds of this Duration to the specified value.
 void setYears(int years)
          Sets the number of years of this Duration to the specified value.
 String toString()
          Returns a string representation of this Duration.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

years

protected int years

months

protected int months

days

protected int days

hours

protected int hours

minutes

protected int minutes

seconds

protected double seconds

negative

protected boolean negative
Constructor Detail

Duration

public Duration()
Create a new Duration with all fields set to zero.


Duration

public Duration(int years,
                int months,
                int days)
Create a new Duration with years, months and days set as specified.

Parameters:
years - the number of years.
months - the number of months.
days - the number of days

Duration

public Duration(int years,
                int months,
                int days,
                int hours,
                int minutes,
                double seconds)
Create a new Duration with all numeric fields set as specified.

Parameters:
years - the number of years.
months - the number of months.
days - the number of days
hours - the number of hours.
minutes - the number of minutes.
seconds - the number of seconds.
Method Detail

getYears

public int getYears()
Returns the number of years of this Duration.

Returns:
number of years of this Duration.

setYears

public void setYears(int years)
Sets the number of years of this Duration to the specified value.

Parameters:
years - the number of years.

getMonths

public int getMonths()
Returns the number of years of this Duration.

Returns:
number of years of this Duration.

setMonths

public void setMonths(int months)
Sets the number of months of this Duration to the specified value.

Parameters:
months - the number of months.

getDays

public int getDays()
Returns the number of years of this Duration.

Returns:
number of years of this Duration.

setDays

public void setDays(int days)
Sets the number of days of this Duration to the specified value.

Parameters:
days - the number of days.

getHours

public int getHours()
Returns the number of years of this Duration.

Returns:
number of years of this Duration.

setHours

public void setHours(int hours)
Sets the number of hours of this Duration to the specified value.

Parameters:
hours - the number of hours.

getMinutes

public int getMinutes()
Returns the number of years of this Duration.

Returns:
number of years of this Duration.

setMinutes

public void setMinutes(int minutes)
Sets the number of minutes of this Duration to the specified value.

Parameters:
minutes - the number of minutes.

getSeconds

public double getSeconds()
Returns the number of years of this Duration.

Returns:
number of years of this Duration.

setSeconds

public void setSeconds(double seconds)
Sets the number of seconds of this Duration to the specified value.

Parameters:
seconds - the number of seconds.

isNegative

public boolean isNegative()
Returns the negative status Duration.

Returns:
status of the negative field of this Duration.

setNegative

public void setNegative(boolean negative)
Sets the negative status of this Duration to the specified value.

Parameters:
negative - the negative status.

parseDuration

public static Duration parseDuration(String str)
Parses the string argument as a Duration. The format of the string should be PyyYmmMddDThhHmmMssS with an optional leading minus sign. The seconds may contain a decimal point.

Parameters:
str - the string to parse
Returns:
the Duration specified by the string.

toString

public String toString()
Returns a string representation of this Duration.

Returns:
a string representation of this Duration.