org.exolab.castor.types

Class DateTime

Implemented Interfaces:
Cloneable, java.io.Serializable

public class DateTime
extends DateTimeBase

Describe an XML schema DateTime.

The format is defined by W3C XML Schema Recommendation and ISO8601 i.e (-)CCYY-MM-DD'T'HH:MM:SS(.SSSSS)(Z|(+|-)hh:mm)

Version:
$Revision: 0000 $
Author:
Edward Kuns
See Also:
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

DateTime()
Default constructor.
DateTime(String date)
Constructs a DateTime from a String.
DateTime(java.util.Date dateRef)
Creates a new XML Schema DateTime instance from a java.util.Date.
DateTime(long dateAsLong)
Creates a new XML Schema DateTime instance from a long that represents a Date.
DateTime(short[] values)
Constructs a XML Schema DateTime instance given all the values of the different date and time (but not time zone) fields.

Method Summary

short[]
getValues()
Returns an array of shorts with all the fields that describe this DateTime type.
static DateTime
parse(String str)
Parses a String into a new DateTime instance.
static DateTime
parseDateTime(String str)
Parses a String into a new DateTime instance.
void
setValues(short[] values)
Sets all the fields to the values provided in an Array.
java.util.Date
toDate()
Converts this DateTime into a local java.util.Date.
long
toLong()
Converts this DateTime into a long value representing a java.util.Date.
String
toString()
Converts this DateTime to a string.

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

DateTime

public DateTime()
Default constructor.

DateTime

public DateTime(String date)
            throws ParseException
Constructs a DateTime from a String. The String is expected to be in W3C Schema DateTime format.
Parameters:
date - the string representing the date

DateTime

public DateTime(java.util.Date dateRef)
Parameters:
dateRef - a java.util.Date to convert.

DateTime

public DateTime(long dateAsLong)
Parameters:
dateAsLong - java.util.Date represented as a long.

DateTime

public DateTime(short[] values)
Parameters:
values - an array of shorts that represent the different fields of Time.

Method Details

getValues

public short[] getValues()
Returns an array of shorts with all the fields that describe this DateTime type. The order of entries in the array is as follows:
  • century
  • year
  • month
  • day
  • hour
  • minute
  • second
  • millisecond
Note:the time zone is not included.
Overrides:
getValues in interface DateTimeBase
Returns:
an array of short with all the fields that describe this Date type.

parse

public static DateTime parse(String str)
            throws ParseException
Parses a String into a new DateTime instance.
Parameters:
str - the string to parse
Returns:
a new DateTime instance with the value of the parsed string.

parseDateTime

public static DateTime parseDateTime(String str)
            throws ParseException
Parses a String into a new DateTime instance.
Parameters:
str - the string to parse
Returns:
a new DateTime instance with the value of the parsed string.

setValues

public void setValues(short[] values)
Overrides:
setValues in interface DateTimeBase
Parameters:
values - An array of shorts containing the values for the DateTime

toDate

public java.util.Date toDate()
Converts this DateTime into a local java.util.Date.
Overrides:
toDate in interface DateTimeBase
Returns:
a local java.util.Date representing this DateTime.

toLong

public long toLong()
Converts this DateTime into a long value representing a java.util.Date.
Returns:
This DateTime instance as a long value representing a java.util.Date.

toString

public String toString()
Converts this DateTime to a string. The format is defined by W3C XML Schema recommendation and ISO8601: (+|-)CCYY-MM-DDTHH:MM:SS.SSS(+/-)HH:SS
Returns:
a string representing this Date

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