org.exolab.castor.types

Class Date

public class Date extends DateTimeBase

Describe an XML schema Date.

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

Version: $Revision: 5951 $

Author: Arnaud Blandin

Field Summary
static StringDATE_FORMAT
The Date Format
Constructor Summary
Date()
Date(short[] values)
Constructs a XML Schema Date instance given all the values of the different fields.
Date(long dateAsLong)
This constructor is used to convert a long value representing a Date to a new org.exolab.castor.types.Date instance.
Date(Date dateRef)
This constructor is used to convert a java.util.Date into a new org.exolab.castor.types.Date

Note : all the information concerning the time part of the java.util.Date is lost since a W3C Schema Date only represents CCYY-MM-YY

Date(String date)
Constructs a date from a string
Method Summary
shortgetHour()
shortgetMilli()
shortgetMinute()
shortgetSeconds()
short[]getValues()
Returns an array of short with all the fields that describe this Date type.
static Objectparse(String str)
parse a String and convert it into an java.lang.Object
static DateparseDate(String str)
parse a String and convert it into a Date.
voidsetHour(short hour)
voidsetMilliSecond(short millisecond)
voidsetMinute(short minute)
voidsetSecond(short second)
voidsetValues(short[] values)
Sets all the fields by reading the values in an array

if a Time Zone is specificied it has to be set by using setZone.

DatetoDate()
converts this Date into a local java Date.
longtoLong()
Converts this date into a long value.
StringtoString()
convert this Date to a string The format is defined by W3C XML Schema recommendation and ISO8601 i.e (+|-)CCYY-MM-DD

Field Detail

DATE_FORMAT

public static final String DATE_FORMAT
The Date Format

Constructor Detail

Date

public Date()

Date

public Date(short[] values)
Constructs a XML Schema Date instance given all the values of the different fields. By default a Date is not UTC and is local.

Parameters: values an array of shorts that represent the different fields of Time.

Date

public Date(long dateAsLong)
This constructor is used to convert a long value representing a Date to a new org.exolab.castor.types.Date instance.

Note : all the information concerning the time part of the java.util.Date is lost since a W3C Schema Date only represents CCYY-MM-YY

Parameters: dateAsLong Date represented in from of a long value.

Date

public Date(Date dateRef)
This constructor is used to convert a java.util.Date into a new org.exolab.castor.types.Date

Note : all the information concerning the time part of the java.util.Date is lost since a W3C Schema Date only represents CCYY-MM-YY

Date

public Date(String date)
Constructs a date from a string

Parameters: date the string representing the date

Method Detail

getHour

public short getHour()

getMilli

public short getMilli()

getMinute

public short getMinute()

getSeconds

public short getSeconds()

getValues

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

Note:the time zone is not included.

Returns: an array of short with all the fields that describe this Date type.

parse

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

Parameters: str the string to parse

Returns: an 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)

parseDate

public static Date parseDate(String str)
parse a String and convert it into a Date.

Parameters: str the string to parse

Returns: the Date 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)

setHour

public void setHour(short hour)

setMilliSecond

public void setMilliSecond(short millisecond)

setMinute

public void setMinute(short minute)

setSecond

public void setSecond(short second)

setValues

public void setValues(short[] values)
Sets all the fields by reading the values in an array

if a Time Zone is specificied it has to be set by using setZone.

Parameters: values an array of shorts with the values the array is supposed to be of length 4 and ordered like the following:

toDate

public Date toDate()
converts this Date into a local java Date.

Returns: a local date representing this Date.

toLong

public long toLong()
Converts this date into a long value.

Returns: This date instance as a long value.

toString

public String toString()
convert this Date to a string The format is defined by W3C XML Schema recommendation and ISO8601 i.e (+|-)CCYY-MM-DD

Returns: a string representing this Date

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