public abstract class DateTimeBase
extends java.lang.Object
implements java.io.Serializable
The base class for date/time XML Schema types.
The validation of the date/time fields is done in the set methods and follows the ISO8601 Date and Time Format.
Note: the castor date/time type are mutable, unlike the date/time types of the JDK in Java2. This is needed by the Marshalling framework.
Date,
Time,
Serialized Form| Modifier and Type | Field and Description |
|---|---|
static int |
EQUALS |
static int |
GREATER_THAN |
static int |
INDETERMINATE
Fields used for comparison methods
|
static int |
LESS_THAN |
protected static java.lang.String |
WRONGLY_PLACED |
| Constructor and Description |
|---|
DateTimeBase() |
| Modifier and Type | Method and Description |
|---|---|
void |
addDuration(Duration duration)
Adds a Duration to this Date/Time type as defined in
Adding Duration to dateTimes (W3C XML Schema, part 2 appendix E).
This version is using the algorithm defined in the document from W3C, next version
may optimize it.
|
int |
compareTo(DateTimeBase dateTime)
Compares two date/time data types.
|
protected boolean |
equal(DateTimeBase dateTime)
Returns true if the present instance of date/time type is equal to
the parameter.
|
boolean |
equals(java.lang.Object object)
Overrides the java.lang.Object#equals method
|
short |
getCentury() |
short |
getDay() |
short |
getHour() |
short |
getMilli() |
short |
getMinute() |
short |
getMonth() |
short |
getSeconds() |
abstract short[] |
getValues()
returns an array of short with all the fields that describe
a date/time type.
|
short |
getYear() |
short |
getZoneHour() |
short |
getZoneMinute() |
int |
hashCode()
Overrides the java.lang.Object#hashcode method.
|
boolean |
isLeap(int year)
Returns true if the given year represents a leap year
A specific year is a leap year if it is either evenly
divisible by 400 OR evenly divisible by 4 and not evenly divisible by 100
|
boolean |
isNegative() |
boolean |
isUTC()
Return true if this date/time type is UTC.
|
boolean |
isZoneNegative() |
void |
normalize()
Normalizes a date/time datatype as defined in W3C XML Schema
Recommendation document:
if a timeZone is present but it is not Z then we convert the date/time datatype
to Z using the addition operation defined in
Adding Duration to dateTimes (W3C XML Schema, part 2 appendix E).
|
void |
setCentury(short century)
set the century field
|
void |
setDay(short day)
set the Day Field
|
void |
setHour(short hour)
set the hour field for this date/time type.
|
void |
setMilliSecond(short millisecond)
Sets the millisecond field for this date/time type
|
void |
setMinute(short minute)
set the minute field for this date/time type.
|
void |
setMonth(short month)
set the Month Field
|
void |
setNegative()
set the negative field to true
|
void |
setSecond(short second)
Sets the second field for this date/time type
|
void |
setSecond(short second,
short millsecond)
set the second field for this date/time type
|
void |
setUTC()
set the UTC field.
|
abstract void |
setValues(short[] values)
Sets all the fields by reading the values in an array
|
void |
setYear(short year)
set the Year field
Note: 0000 is not allowed
|
void |
setZone(short hour,
short minute)
Sets the time zone fields for this date/time type.
|
void |
setZoneHour(short hour)
Sets the time zone hour field for this date/time type.
|
void |
setZoneMinute(short minute)
Sets the time zone minute field for this date/time type.
|
void |
setZoneNegative(boolean zoneNegative)
set the time zone negative field to true
|
java.util.Calendar |
toCalendar()
converts this Date/Time into a local java Calendar.
|
abstract java.util.Date |
toDate()
Returns a java.util.Date that represents
the XML Schema Date datatype
|
public static final int INDETERMINATE
public static final int LESS_THAN
public static final int EQUALS
public static final int GREATER_THAN
protected static final java.lang.String WRONGLY_PLACED
public void setCentury(short century)
century - the value to set uppublic void setYear(short year)
throws OperationNotSupportedException
year - year to set upOperationNotSupportedExceptionpublic void setMonth(short month)
throws OperationNotSupportedException
month - the value to set up
Note 1OperationNotSupportedExceptionpublic void setDay(short day)
throws OperationNotSupportedException
day - the value to set up
Note a validation is done on the day fieldOperationNotSupportedExceptionpublic final boolean isLeap(int year)
year - the year to test.public void setHour(short hour)
throws OperationNotSupportedException
hour - the hour to setOperationNotSupportedException - this exception is thrown when
changing the value of the hour field is not allowedpublic void setMinute(short minute)
throws OperationNotSupportedException
minute - the minute to set.OperationNotSupportedException - this exception is thrown when
changing the value of the minute field is not allowedpublic void setSecond(short second,
short millsecond)
throws OperationNotSupportedException
second - the second to setmillsecond - the millisecond to setOperationNotSupportedException - this exception is thrown when
changing the value of the second field is not allowedpublic void setSecond(short second)
throws OperationNotSupportedException
second - the second to setOperationNotSupportedException - this exception is thrown when
changing the value of the second field is not allowedpublic void setMilliSecond(short millisecond)
throws OperationNotSupportedException
millisecond - the millisecond to setOperationNotSupportedException - this exception is thrown when
changing the value of the second field is not allowedpublic void setZone(short hour,
short minute)
throws OperationNotSupportedException
hour - the time zone hour to setminute - the time zone minute to setOperationNotSupportedException - this exception is thrown when
changing the value of the time zone fields is not allowedpublic void setZoneHour(short hour)
throws OperationNotSupportedException
hour - the time zone hour to setOperationNotSupportedException - this exception is thrown when
changing the value of the time zone fields is not allowedpublic void setZoneMinute(short minute)
throws OperationNotSupportedException
minute - the time zone minute to setOperationNotSupportedException - this exception is thrown when
changing the value of the time zone fields is not allowedpublic abstract void setValues(short[] values)
values - an array of shorts with the valuespublic void setNegative()
public abstract java.util.Date toDate()
public void setZoneNegative(boolean zoneNegative)
throws OperationNotSupportedException
OperationNotSupportedException - this exception is thrown when
changing the time zone fields is not allowedpublic void setUTC()
public short getCentury()
public short getYear()
public short getMonth()
public short getDay()
public short getHour()
public short getMinute()
public short getSeconds()
public short getMilli()
public short getZoneHour()
public short getZoneMinute()
public abstract short[] getValues()
public boolean isUTC()
public boolean isNegative()
public boolean isZoneNegative()
public void addDuration(Duration duration)
Adds a Duration to this Date/Time type as defined in Adding Duration to dateTimes (W3C XML Schema, part 2 appendix E). This version is using the algorithm defined in the document from W3C, next version may optimize it.
duration - the duration to addpublic void normalize()
Normalizes a date/time datatype as defined in W3C XML Schema Recommendation document: if a timeZone is present but it is not Z then we convert the date/time datatype to Z using the addition operation defined in Adding Duration to dateTimes (W3C XML Schema, part 2 appendix E).
public int compareTo(DateTimeBase dateTime)
Compares two date/time data types. The algorithm of comparison is defined in W3C XML Schema Recommendation (section 3.2.7.3)
The returned values can be:
dateTime - the dateTime to compare with the current instance.public int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object object)
equals in class java.lang.Objectequals(Object)protected boolean equal(DateTimeBase dateTime)
Returns true if the present instance of date/time type is equal to the parameter.
The equals relation is as defined in the W3C XML Schema Recommendation, part2.
dateTime - the date/time type to compare with the present instancepublic java.util.Calendar toCalendar()
Intalio Inc. (C) 1999-2006. All rights reserved http://www.intalio.com