org.exolab.castor.types

Class Time

Implemented Interfaces:
Cloneable, java.io.Serializable

public class Time
extends DateTimeBase

Describes an XML schema Time.

The format is defined by W3C XML Schema Recommendation and ISO8601 i.e hh:mm:ss.sss(Z|(+|-)hh:mm)

Deep support of fractional seconds is not implemented. This implementation only supports fractional second resolution of milliseconds.

Version:
$Revision: 7289 $
Authors:
Arnaud Blandin
Edward Kuns
See Also:
DateTimeBase, Serialized Form

Field Summary

Fields inherited from class org.exolab.castor.types.DateTimeBase

EQUALS, GREATER_THAN, INDETERMINATE, LESS_THAN, MAX_TIME_ZONE_COMPARISON_OFFSET, WRONGLY_PLACED

Constructor Summary

Time()
No-arg constructor.
Time(String time)
Constructs a Time given a string representation.
Time(long l)
Constructs a XML Schema Time instance given a long representing the time in milliseconds.
Time(short[] values)
Constructs a XML Schema Time instance given all the values of the different fields.

Method Summary

short
getCentury()
short
getDay()
short
getMonth()
short[]
getValues()
returns an array of short with all the fields that describe this time type.
short
getYear()
boolean
hasCentury()
boolean
hasDay()
boolean
hasIsNegative()
boolean
hasMonth()
boolean
hasYear()
boolean
isNegative()
static Object
parse(String str)
parses a String and converts it into a java.lang.Object
static Time
parseTime(String str)
parses a String and converts it into a Time.
void
setCentury(short century)
void
setDay(short month)
void
setMonth(short month)
void
setNegative()
void
setValues(short[] values)
Sets all the fields by reading the values in an array.
void
setYear(short year)
Date
toDate()
converts this Time into a local java Date.
String
toString()
convert this Time to a string The format is defined by W3C XML Schema Recommendation and ISO8601 i.e hh:mm:ss.sss(Z|(+|-)hh:mm)

Methods inherited from class org.exolab.castor.types.DateTimeBase

addDuration, appendDateString, appendTimeString, appendTimeZoneString, clone, compareTo, equal, equals, getCentury, getDay, getHour, getMilli, getMinute, getMonth, getSeconds, getValues, getYear, getZoneHour, getZoneMinute, hasCentury, hasDay, hasHour, hasIsNegative, hasMilli, hasMinute, hasMonth, hasSeconds, hasYear, hashCode, isLeap, isNegative, isUTC, isZoneNegative, normalize, parseDay, parseMonth, parseTime, parseTimeZone, parseYear, setCentury, setDateFormatTimeZone, setDateFormatTimeZone, setDay, setHour, setMilliSecond, setMinute, setMonth, setNegative, setSecond, setSecond, setUTC, setValues, setYear, setZone, setZoneHour, setZoneMinute, setZoneNegative, toCalendar, toDate

Constructor Details

Time

public Time()
No-arg constructor.

Time

public Time(String time)
            throws ParseException
Constructs a Time given a string representation.
Parameters:
time - the string representation of the Time to instantiate

Time

public Time(long l)
Constructs a XML Schema Time instance given a long representing the time in milliseconds. By default a Time is not UTC and is local.
Parameters:
l - The long value that represents the time instance.

Time

public Time(short[] values)
Constructs a XML Schema Time instance given all the values of the different fields. By default a Time is not UTC and is local.
Parameters:
values - an array of shorts that represent the different fields of Time.

Method Details

getCentury

public short getCentury()
Overrides:
getCentury in interface DateTimeBase

getDay

public short getDay()
Overrides:
getDay in interface DateTimeBase

getMonth

public short getMonth()
Overrides:
getMonth in interface DateTimeBase

getValues

public short[] getValues()
returns an array of short with all the fields that describe this time type.

Note:the time zone is not included.

Overrides:
getValues in interface DateTimeBase
Returns:
an array of short with all the fields that describe this time type.

getYear

public short getYear()
Overrides:
getYear in interface DateTimeBase

hasCentury

public boolean hasCentury()
Overrides:
hasCentury in interface DateTimeBase

hasDay

public boolean hasDay()
Overrides:
hasDay in interface DateTimeBase

hasIsNegative

public boolean hasIsNegative()
Overrides:
hasIsNegative in interface DateTimeBase

hasMonth

public boolean hasMonth()
Overrides:
hasMonth in interface DateTimeBase

hasYear

public boolean hasYear()
Overrides:
hasYear in interface DateTimeBase

isNegative

public boolean isNegative()
Overrides:
isNegative in interface DateTimeBase

parse

public static Object parse(String str)
            throws ParseException
parses a String and converts it into a java.lang.Object
Parameters:
str - the string to parse
Returns:
the java.lang.Object represented by the string

parseTime

public static Time parseTime(String str)
            throws ParseException
parses a String and converts it into a Time.
Parameters:
str - the string to parse
Returns:
the Time represented by the string

setCentury

public void setCentury(short century)
Overrides:
setCentury in interface DateTimeBase

setDay

public void setDay(short month)
Overrides:
setDay in interface DateTimeBase

setMonth

public void setMonth(short month)
Overrides:
setMonth in interface DateTimeBase

setNegative

public void setNegative()
Overrides:
setNegative in interface DateTimeBase

setValues

public void setValues(short[] values)
Overrides:
setValues in interface DateTimeBase
Parameters:
values - an array of shorts with the values the array is supposed to be of length 4 and ordered like that:
  • hour
  • minute
  • second
  • millisecond

setYear

public void setYear(short year)
Overrides:
setYear in interface DateTimeBase

toDate

public Date toDate()
converts this Time into a local java Date.
Overrides:
toDate in interface DateTimeBase
Returns:
a local date representing this Time

toString

public String toString()
convert this Time to a string The format is defined by W3C XML Schema Recommendation and ISO8601 i.e hh:mm:ss.sss(Z|(+|-)hh:mm)
Returns:
a string representing this Time

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