org.exolab.castor.types
Class DateTime
- Cloneable, java.io.Serializable
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)
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.
|
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.
|
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 |
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.
date
- the string representing the date
DateTime
public DateTime(java.util.Date dateRef)
Creates a new XML Schema DateTime instance from a java.util.Date. No time
zone information is set.
By default a DateTime is not UTC, and is local. To set a timezone, you
need to separately call
setZone(short,short)
.
dateRef
- a java.util.Date to convert.
DateTime
public DateTime(long dateAsLong)
Creates a new XML Schema DateTime instance from a long that represents a
Date. No time zone information is set.
By default a DateTime is not UTC, and is local. To set a timezone, you
need to separately call
setZone(short,short)
.
dateAsLong
- java.util.Date represented as a long.
DateTime
public DateTime(short[] values)
Constructs a XML Schema DateTime instance given all the values of the
different date and time (but not time zone) fields.
By default a DateTime is not UTC, and is local. To set a timezone, you
need to separately call
setZone(short,short)
.
values
- an array of shorts that represent the different fields of
Time.
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.
- getValues in interface DateTimeBase
- 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.
str
- the string to parse
- 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.
str
- the string to parse
- a new DateTime instance with the value of the parsed string.
setValues
public void setValues(short[] values)
Sets all the fields to the values provided in an Array. The Array must
be at least eight entries long. Extra entries are ignored. The order of
entries in the array is as follows:
- century
- year
- month
- day
- hour
- minute
- second
- millisecond
If a Time Zone is to be specified, it has to be set separately by using
setZone
. A time zone
previously set will not be cleared.
- setValues in interface DateTimeBase
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.
- toDate in interface DateTimeBase
- a local java.util.Date representing this DateTime.
toLong
public long toLong()
Converts this DateTime into a long value representing a java.util.Date.
- 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
- a string representing this Date
Intalio Inc. (C) 1999-2008. All rights reserved http://www.intalio.com