org.exolab.castor.xml.handlers
Class DateFieldHandler
- FieldHandler
public class DateFieldHandler
A specialized FieldHandler for the XML Schema
Date/Time related types
$Revision: 1.5 $ $Date: 2003/05/30 04:58:07 $
boolean | equals(Object obj) - Returns true if the given object is an XMLFieldHandler that
is equivalent to the delegated handler.
|
protected static String | format(Date date) - Returns the given date in a String format, using the
ISO8601 format as specified in the W3C XML Schema 1.0
Recommendation (Part 2: Datatypes) for dataTime.
|
Object | getValue(Object target) - Returns the value of the field associated with this
descriptor from the given target object.
|
Object | newInstance(Object parent) - Creates a new instance of the object described by this field.
|
protected static Date | parse(String dateTime) - Parses the given string, which must be in the following format:
CCYY-MM-DDThh:mm:ss or CCYY-MM-DDThh:mm:ss.sss
where "CC" represents the century, "YY" the year, "MM" the
month and "DD" the day.
|
void | resetValue(Object target)
|
static void | setAllowTimeZoneSuppression(boolean allowTimeZoneSuppression) - Sets whether or not UTC time should always be used when
marshalling out xsd:dateTime values.
|
static void | setDefaultTimeZone(TimeZone timeZone) - Sets the default TimeZone used for comparing dates when marshalling out
xsd:dateTime values using this handler.
|
void | setValue(Object target, Object value) - Sets the value of the field associated with this descriptor.
|
DateFieldHandler
public DateFieldHandler(FieldHandler fieldHandler)
Creates a new DateFieldHandler using the given
FieldHandler for delegation.
fieldHandler
- the fieldHandler for delegation.
equals
public boolean equals(Object obj)
Returns true if the given object is an XMLFieldHandler that
is equivalent to the delegated handler. An equivalent XMLFieldHandler
is an XMLFieldHandler that is an instances of the same class.
- equals in interface XMLFieldHandler
- true if the given object is an XMLFieldHandler that
is equivalent to this one.
format
protected static String format(Date date)
Returns the given date in a String format, using the
ISO8601 format as specified in the W3C XML Schema 1.0
Recommendation (Part 2: Datatypes) for dataTime.
date
- the Date to format
getValue
public Object getValue(Object target)
throws java.lang.IllegalStateException
Returns the value of the field associated with this
descriptor from the given target object.
- getValue in interface FieldHandler
- getValue in interface XMLFieldHandler
target
- the object to get the value from
- the value of the field associated with this
descriptor from the given target object.
newInstance
public Object newInstance(Object parent)
throws IllegalStateException
Creates a new instance of the object described by this field.
- newInstance in interface FieldHandler
- newInstance in interface XMLFieldHandler
parent
- The object for which the field is created
- A new instance of the field's value
parse
protected static Date parse(String dateTime)
throws ParseException
Parses the given string, which must be in the following format:
CCYY-MM-DDThh:mm:ss or CCYY-MM-DDThh:mm:ss.sss
where "CC" represents the century, "YY" the year, "MM" the
month and "DD" the day. The letter "T" is the date/time
separator and "hh", "mm", "ss" represent hour, minute and
second respectively.
CCYY represents the Year and each 'C' and 'Y' must be a digit
from 0-9. A minimum of 4 digits must be present.
MM represents the month and each 'M' must be a digit from 0-9,
but together "MM" must not represent a value greater than 12.
"MM" must be 2 digits, use of leading zero is required for
all values less than 10.
DD represents the day of the month and each 'D' must be a digit
from 0-9. DD must be 2 digits (use a leading zero if necessary)
and must not be greater than 31.
'T' is the date/time separator and must exist!
hh represents the hour using 0-23.
mm represents the minute using 0-59.
ss represents the second using 0-60. (60 for leap second)
sss represents the millisecond using 0-999.
dateTime
- the string to convert to a Date
- a new Date that represents the given string.
setAllowTimeZoneSuppression
public static void setAllowTimeZoneSuppression(boolean allowTimeZoneSuppression)
Sets whether or not UTC time should always be used when
marshalling out xsd:dateTime values.
setDefaultTimeZone
public static void setDefaultTimeZone(TimeZone timeZone)
Sets the default TimeZone used for comparing dates when marshalling out
xsd:dateTime values using this handler. This is used when determining
if the timezone can be omitted when marshalling.
Default is JVM default returned by TimeZone.getDefault()
timeZone
- TimeZone to use instead of JVM default
setAllowTimeZoneSuppression
setValue
public void setValue(Object target,
Object value)
throws java.lang.IllegalStateException
Sets the value of the field associated with this descriptor.
- setValue in interface FieldHandler
- setValue in interface XMLFieldHandler
target
- the object in which to set the valuevalue
- the value of the field
Intalio Inc. (C) 1999-2003. All rights reserved http://www.intalio.com