|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.exolab.castor.types.DateTimeBase
public abstract class DateTimeBase
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 types are mutable, unlike the date/time types of the JDK in Java2. This is needed by the Marshaling framework.
DateTime,
Date,
Time,
Serialized Form| Field Summary | |
|---|---|
static int |
EQUALS
Public constant referring to a Date/Time comparison result of "equals". |
static int |
GREATER_THAN
Public constant referring to a Date/Time comparison result of "greater than". |
static int |
INDETERMINATE
Public constant referring to an indeterminate Date/Time comparison. |
static int |
LESS_THAN
Public constant referring to a Date/Time comparison result of "less than". |
protected static int |
MAX_TIME_ZONE_COMPARISON_OFFSET
When comparing a date/time with a time zone to one without, the recommendation says that 14 hours is the time zone offset to use for comparison. |
protected static String |
WRONGLY_PLACED
Convenience String for complaints. |
| Constructor Summary | |
|---|---|
DateTimeBase()
|
|
| Method Summary | |
|---|---|
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). |
protected void |
appendDateString(StringBuffer result)
|
protected void |
appendTimeString(StringBuffer result)
|
protected void |
appendTimeZoneString(StringBuffer result)
|
DateTimeBase |
clone(DateTimeBase dateTime)
|
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(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()
|
boolean |
hasCentury()
|
boolean |
hasDay()
|
int |
hashCode()
Overrides the java.lang.Object#hashcode method. |
boolean |
hasHour()
|
boolean |
hasIsNegative()
|
boolean |
hasMilli()
|
boolean |
hasMinute()
|
boolean |
hasMonth()
|
boolean |
hasSeconds()
|
boolean |
hasYear()
|
boolean |
isLeap(int year)
Returns true if the given year represents a leap year. |
boolean |
isNegative()
|
boolean |
isUTC()
Returns true if this date/time type is UTC, that is, has a time zone assigned. |
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). |
protected static int |
parseDay(String str,
DateTimeBase result,
char[] chars,
int index,
String complaint)
|
protected static int |
parseMonth(String str,
DateTimeBase result,
char[] chars,
int index,
String complaint)
|
protected static int |
parseTime(String str,
DateTimeBase result,
char[] chars,
int index,
String complaint)
|
protected static int |
parseTimeZone(String str,
DateTimeBase result,
char[] chars,
int index,
String complaint)
|
protected static int |
parseYear(String str,
DateTimeBase result,
char[] chars,
int index,
String complaint)
|
void |
setCentury(short century)
Set the century field. |
protected void |
setDateFormatTimeZone(Calendar calendar)
Sets the time zone in the provided Calendar. |
protected void |
setDateFormatTimeZone(DateFormat df)
Sets the time zone in the provided DateFormat. |
void |
setDay(short day)
Sets the Day Field. |
void |
setHour(short hour)
Sets 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)
Sets the Month Field. |
void |
setNegative()
Set the negative field to true. |
void |
setSecond(short second)
Sets the seconds field for this date/time type, not including the fractional seconds. |
void |
setSecond(short second,
short millsecond)
Sets the seconds field for this date/time type, including fractional seconds. |
void |
setUTC()
Sets the UTC field. |
abstract void |
setValues(short[] values)
Sets all the fields by reading the values in an array. |
void |
setYear(short year)
Sets the Year field. |
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)
Sets the time zone negative field to true. |
Calendar |
toCalendar()
converts this Date/Time into a local java Calendar. |
abstract Date |
toDate()
Returns a java.util.Date that represents the XML Schema Date datatype. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
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 int MAX_TIME_ZONE_COMPARISON_OFFSET
protected static final String WRONGLY_PLACED
| Constructor Detail |
|---|
public DateTimeBase()
| Method Detail |
|---|
public abstract Date toDate()
public abstract void setValues(short[] values)
values - an array of shorts with the values.public abstract short[] getValues()
public final boolean isLeap(int year)
year - the year to test where 0 < year <= 9999
public void setNegative()
throws UnsupportedOperationException
UnsupportedOperationException - this exception is thrown when changing the value of the
"century+year is negative" field is not allowed.
public void setCentury(short century)
throws UnsupportedOperationException
century - the value to set
UnsupportedOperationException - this exception is thrown when changing the value of the
century field is not allowed
public void setYear(short year)
throws UnsupportedOperationException
year - the year to set
UnsupportedOperationException - in an overridden method in a derived class if that derived
class does not support the year element.
public void setMonth(short month)
throws UnsupportedOperationException
month - the value to set up
UnsupportedOperationException - in an overridden method in a derived class if that derived
class does not support the month element.
public void setDay(short day)
throws UnsupportedOperationException
day - the value to set up
UnsupportedOperationException - in an overridden method in a derived class if that derived
class does not support the day element.
public void setHour(short hour)
throws UnsupportedOperationException
hour - the hour to set
UnsupportedOperationException - this exception is thrown when changing the value of the hour
field is not allowed
public void setMinute(short minute)
throws UnsupportedOperationException
minute - the minute to set.
UnsupportedOperationException - this exception is thrown when changing the value of the
minute field is not allowed
public void setSecond(short second,
short millsecond)
throws UnsupportedOperationException
second - the second to setmillsecond - the millisecond to set
UnsupportedOperationException - this exception is thrown when changing the value of the
second field is not allowed
public void setSecond(short second)
throws UnsupportedOperationException
second - the second to set
UnsupportedOperationException - this exception is thrown when changing the value of the
second field is not allowed
public void setMilliSecond(short millisecond)
throws UnsupportedOperationException
millisecond - the millisecond to set
UnsupportedOperationException - this exception is thrown when changing the value of the
millisecond field is not allowedpublic void setUTC()
public void setZoneNegative(boolean zoneNegative)
zoneNegative - indicates whether or not the time zone is negative.
UnsupportedOperationException - this exception is thrown when changing the time zone fields
is not allowed
public void setZone(short hour,
short minute)
For a negative time zone, you first assign the absolute value of the time
zone using this method and then you call
setZoneNegative(boolean).
hour - The time zone hour to set. Must be positive.minute - The time zone minute to set.
UnsupportedOperationException - this exception is thrown when changing the value of the time
zone fields is not allowedpublic void setZoneHour(short hour)
For a negative time zone, you first assign the absolute value of the time
zone using this method and then you call
setZoneNegative(boolean).
hour - the time zone hour to set. Must be positive.
UnsupportedOperationException - this exception is thrown when changing the value of the time
zone fields is not allowedpublic void setZoneMinute(short minute)
minute - the time zone minute to set
UnsupportedOperationException - this exception is thrown when changing the value of the time
zone fields is not allowed
public boolean isNegative()
throws UnsupportedOperationException
UnsupportedOperationException
public short getCentury()
throws UnsupportedOperationException
UnsupportedOperationException
public short getYear()
throws UnsupportedOperationException
UnsupportedOperationException
public short getMonth()
throws UnsupportedOperationException
UnsupportedOperationException
public short getDay()
throws UnsupportedOperationException
UnsupportedOperationException
public short getHour()
throws UnsupportedOperationException
UnsupportedOperationException
public short getMinute()
throws UnsupportedOperationException
UnsupportedOperationException
public short getSeconds()
throws UnsupportedOperationException
UnsupportedOperationException
public short getMilli()
throws UnsupportedOperationException
UnsupportedOperationExceptionpublic boolean isUTC()
public boolean isZoneNegative()
public short getZoneHour()
public short getZoneMinute()
public boolean hasIsNegative()
public boolean hasCentury()
public boolean hasYear()
public boolean hasMonth()
public boolean hasDay()
public boolean hasHour()
public boolean hasMinute()
public boolean hasSeconds()
public boolean hasMilli()
public void addDuration(Duration duration)
The modified Date/Time instance will keep the same time zone it started with, if any.
Don't use getter methods but use direct field access for dateTime in order to have the behaviour defined in the Recommendation document.
duration - the duration to addpublic void normalize()
addDuration(org.exolab.castor.types.Duration)public int compareTo(DateTimeBase dateTime)
The returned value will be one of:
FIXME: This code does not compare time zones properly for date/time types that do not contain a time.
dateTime - the dateTime to compare with the current instance.
public DateTimeBase clone(DateTimeBase dateTime)
throws CloneNotSupportedException
CloneNotSupportedExceptionpublic int hashCode()
hashCode in class Objectpublic boolean equals(Object object)
equals in class Objectequals(Object)protected boolean equal(DateTimeBase dateTime)
The equals relation is as defined in the W3C XML Schema Recommendation, part2.
dateTime - the date/time type to compare with the present instance
public Calendar toCalendar()
protected static int parseYear(String str,
DateTimeBase result,
char[] chars,
int index,
String complaint)
throws ParseException
ParseException
protected static int parseMonth(String str,
DateTimeBase result,
char[] chars,
int index,
String complaint)
throws ParseException
ParseException
protected static int parseDay(String str,
DateTimeBase result,
char[] chars,
int index,
String complaint)
throws ParseException
ParseException
protected static int parseTime(String str,
DateTimeBase result,
char[] chars,
int index,
String complaint)
throws ParseException
ParseException
protected static int parseTimeZone(String str,
DateTimeBase result,
char[] chars,
int index,
String complaint)
throws ParseException
ParseExceptionprotected void setDateFormatTimeZone(DateFormat df)
df - protected void setDateFormatTimeZone(Calendar calendar)
calendar - protected void appendDateString(StringBuffer result)
protected void appendTimeString(StringBuffer result)
protected void appendTimeZoneString(StringBuffer result)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||