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.
EQUALS
public static final int EQUALS
- 1
GREATER_THAN
public static final int GREATER_THAN
- 2
INDETERMINATE
public static final int INDETERMINATE
Fields used for comparison methods
- -1
LESS_THAN
public static final int LESS_THAN
- 0
WRONGLY_PLACED
protected static final String WRONGLY_PLACED
addDuration
public void addDuration(Duration duration)
compareTo
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:
- INDETERMINATE (-1): this ? dateTime
- LESS_THAN (0): this <32dateTime
- EQUALS (1): this == dateTime
- GREATER_THAN (2): this > dateTime
dateTime
- the dateTime to compare with the current instance.
- INDETERMINATE (-1)
- LESS_THAN (0)
- EQUALS (1)
- GREATER_THAN (2)
equal
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 instance
- true if the present instance is equal to the parameter false if not
equals
public boolean equals(Object object)
Overrides the java.lang.Object#equals method
equal(DateTimeBase)
getCentury
public short getCentury()
getDay
public short getDay()
getHour
public short getHour()
getMilli
public short getMilli()
getMinute
public short getMinute()
getMonth
public short getMonth()
getSeconds
public short getSeconds()
getValues
public short[] getValues()
returns an array of short with all the fields that describe
a date/time type.
- an array of short with all the fields that describe
a date/time type.
getYear
public short getYear()
getZoneHour
public short getZoneHour()
getZoneMinute
public short getZoneMinute()
hashCode
public int hashCode()
Overrides the java.lang.Object#hashcode method.
isLeap
public final 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
year
- the year to test.
- true if the given year represents a leap year
isNegative
public boolean isNegative()
isUTC
public boolean isUTC()
return true if this date/time type is UTC.
A date/time type is UTC if a 'Z' appears at the end of the
lexical representation type or if it contains a time zone.
isZoneNegative
public boolean isZoneNegative()
setCentury
public void setCentury(short century)
set the century field
century
- the value to set up
setDay
public void setDay(short day)
throws OperationNotSupportedException
set the Day Field
day
- the value to set up
Note a validation is done on the day field
setNegative
public void setNegative()
set the negative field to true
setSecond
public void setSecond(short second,
short millsecond)
throws OperationNotSupportedException
set the second field for this date/time type
second
- the second to setmillsecond
- the millisecond to set
OperationNotSupportedException
- this exception is thrown when
changing the value of the second field is not allowed
setUTC
public void setUTC()
set the UTC field.
setValues
public void setValues(short[] values)
Sets all the fields by reading the values in an array
values
- an array of shorts with the values
setZone
public void setZone(short hour,
short minute)
throws OperationNotSupportedException
Sets the time zone fields for this date/time type.
A call to this method means that the date/time type
used is UTC.
hour
- the time zone hour to setminute
- the time zone minute to set
OperationNotSupportedException
- this exception is thrown when
changing the value of the time zone fields is not allowed
setZoneHour
public void setZoneHour(short hour)
throws OperationNotSupportedException
Sets the time zone hour field for this date/time type.
A call to this method means that the date/time type
used is UTC.
hour
- the time zone hour to set
OperationNotSupportedException
- this exception is thrown when
changing the value of the time zone fields is not allowed
setZoneMinute
public void setZoneMinute(short minute)
throws OperationNotSupportedException
Sets the time zone minute field for this date/time type.
A call to this method means that the date/time type
used is UTC.
minute
- the time zone minute to set
OperationNotSupportedException
- this exception is thrown when
changing the value of the time zone fields is not allowed
toCalendar
public Calendar toCalendar()
converts this Date/Time into a local java Calendar.
- a local calendar representing this Date or Time
toDate
public Date toDate()
Returns a java.util.Date that represents
the XML Schema Date datatype