org.exolab.castor.types

Class TimeDuration

public class TimeDuration extends Object implements Serializable

Represents the timeDuration XML Schema type.

This representation does not support the decimal fraction for the lowest order item. Besides setting TimeDuration to '0' is not possible thus there is no distinction between '0' and 'P0Y'

Version: $Revision: 1.2 $ $Date: 2005/03/05 13:41:56 $

Author: Arnaud Blandin

Constructor Summary
TimeDuration()
default constructor
TimeDuration(long l)

This constructor fills in the time duration fields according to the value of the long by calling setValue

Method Summary
booleanequal(TimeDuration timeD)
Returns true if the instance of TimeDuration has the same fields of the parameter
booleanequals(Object object)
Override the java.lang.equals method
shortgetDay()
shortgetHour()
shortgetMilli()
shortgetMinute()
shortgetMonth()
shortgetSeconds()
shortgetYear()
booleanisGreater(TimeDuration timeD)

Returns true if the present instance of TimeDuration is greater than the parameter

Note This definition does not follow the XML SCHEMA DRAFT 20001024 the following orger relation is used : t1,t2 timeDuration types t1>t2 iff t1.toLong()>t2.toLong()

booleanisNegative()
static Objectparse(String str)
parse a String and convert it into a java.lang.Object
static TimeDurationparseTimeDuration(String str)

Parse the given string and return a time duration which represents this string

voidsetDay(short day)
voidsetHour(short hour)
voidsetMilli(short milli)
voidsetMinute(short minute)
voidsetMonth(short month)
voidsetNegative()
voidsetSeconds(short second)
voidsetValue(short year, short month, short day, short hour, short minute, short second, short millisecond)
Fill in the fields of the TimeDuration with the given values
voidsetYear(short year)
longtoLong()

Convert a timeDuration into a long This long represents the duration in milliseconds

StringtoString()

Convert a timeDuration into a String conforming to ISO8601 and XML Schema specs

Constructor Detail

TimeDuration

public TimeDuration()
default constructor

TimeDuration

public TimeDuration(long l)

This constructor fills in the time duration fields according to the value of the long by calling setValue

Parameters: l the long value of the Time Duration

See Also: TimeDuration

Method Detail

equal

public boolean equal(TimeDuration timeD)
Returns true if the instance of TimeDuration has the same fields of the parameter

Parameters: timeD the time duration to compare

Returns: true if equal, false if not

equals

public boolean equals(Object object)
Override the java.lang.equals method

See Also: TimeDuration

getDay

public short getDay()

getHour

public short getHour()

getMilli

public short getMilli()

getMinute

public short getMinute()

getMonth

public short getMonth()

getSeconds

public short getSeconds()

getYear

public short getYear()

isGreater

public boolean isGreater(TimeDuration timeD)

Returns true if the present instance of TimeDuration is greater than the parameter

Note This definition does not follow the XML SCHEMA DRAFT 20001024 the following orger relation is used : t1,t2 timeDuration types t1>t2 iff t1.toLong()>t2.toLong()

Parameters: timeD the time duration to compare with the present instance

Returns: true if the present instance is the greatest, false if not

isNegative

public boolean isNegative()

parse

public static Object parse(String str)
parse a String and convert it into a java.lang.Object

Parameters: str the string to parse

Returns: the java.lang.Object represented by the string

Throws: ParseException a parse exception is thrown if the string to parse does not follow the rigth format (see the description of this class)

parseTimeDuration

public static TimeDuration parseTimeDuration(String str)

Parse the given string and return a time duration which represents this string

Parameters: str the string to parse

Returns: a TimeDuration instance which represent the string

Throws: ParseException thrown when the string is not valid

setDay

public void setDay(short day)

setHour

public void setHour(short hour)

setMilli

public void setMilli(short milli)

setMinute

public void setMinute(short minute)

setMonth

public void setMonth(short month)

setNegative

public void setNegative()

setSeconds

public void setSeconds(short second)

setValue

public void setValue(short year, short month, short day, short hour, short minute, short second, short millisecond)
Fill in the fields of the TimeDuration with the given values

Parameters: year the year value month the month value day the day value hour the hour value minute the minute value second the second value

setYear

public void setYear(short year)

toLong

public long toLong()

Convert a timeDuration into a long This long represents the duration in milliseconds

Returns: a long representing the duration

toString

public String toString()

Convert a timeDuration into a String conforming to ISO8601 and XML Schema specs

Returns: a string representing the time duration

Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com