public final class DateStructImpl extends Object implements DateStruct, Serializable, Cloneable
Implementation of the date component of timestamp values that are specified according to Coordinated Universal Time (UTC). AAF dates represent dates with year, month and day of the month components.
As specified, AAF dates do not represent the timezone associated with a date and in this
sense are not fully compatible with UTC dates. Internally, this class uses the
Calendar class with its support for internationalization so
timezone is represented when provided through methods such as getDateValue().
Also, this class restricts the acceptable range of values to acceptable values, which
includes checking for leap years and unacceptable dates such as 31st February.
A date structure is represented in the database by a column of type date:
`Date` date
| Constructor and Description |
|---|
DateStructImpl()
Create a new date structure for the current date.
|
DateStructImpl(byte day,
byte month,
short year)
Create a new date value using the given year, month and day of the month values.
|
DateStructImpl(Calendar dateItem)
Create a new date structure from a
Calendar value. |
| Modifier and Type | Method and Description |
|---|---|
DateStruct |
clone()
Create a cloned copy of this date value.
|
boolean |
equals(Object o)
Tests to see if this date structure has an equal value to the date structure
passed in.
|
static void |
generateEmbeddableORM(Node parent,
String namespace,
String prefix) |
static void |
generateEmbeddedORM(Node parent,
String ownerName,
String namespace,
String prefix) |
Calendar |
getDateValue()
Returns a copy of the
Calendar value representing the
day given by this date. |
byte |
getDay()
Returns the day of the month component of the date.
|
byte |
getMonth()
Returns the month component of the date, which is in the range 1 to 12.
|
short |
getYear()
Returns the year component of the date.
|
int |
hashCode() |
static DateStructImpl |
parseFactory(String date)
Create a new date structure value from a string representation of a date.
|
void |
setDate(byte day,
byte month,
short year)
Simultaneously set the components of date structure value with the given day,
month and year.
|
void |
setDateValue(Calendar dateItem)
Set the
Calendar value used internally to represent this
date value. |
void |
setDay(byte day)
Set the day of the month component of the date, in the range 1 to 31.
|
void |
setMonth(byte month)
Set the month component of the date, which is in the range 1 to 12.
|
void |
setYear(short year)
Sets the year component of the date, in the range -9999 to 9999.
|
String |
toString()
Formats the date value as a UTC date-only value.
|
public DateStructImpl(@UInt8 byte day, @UInt8 byte month, @Int16 short year) throws IllegalArgumentException
Create a new date value using the given year, month and day of the month values.
day - Day component of the date.month - Month component of the date.year - Year component of the date.IllegalArgumentException - One or more of the arguments has a value outside of
an acceptable range.public DateStructImpl(Calendar dateItem) throws NullPointerException, IllegalArgumentException
Create a new date structure from a Calendar value.
Note that the newly created date structure may not store the timezone and other locale information encoded in the original calendar value.
dateItem - Calendar value to use to extract a day, month and year from.NullPointerException - Argument is null.IllegalArgumentExceptionpublic DateStructImpl()
Create a new date structure for the current date.
public void setDate(@UInt8 byte day, @UInt8 byte month, @Int16 short year) throws IllegalArgumentException
DateStructSimultaneously set the components of date structure value with the given day, month and year.
setDate in interface DateStructday - Day of the month component of the date.month - Month component of the date.year - Year component of the date.IllegalArgumentException - One or more of the component values is outside the acceptable
range for their values, or the specified date does not exist.@UInt8 public final byte getDay()
DateStructReturns the day of the month component of the date.
getDay in interface DateStructpublic final void setDay(@UInt8 byte day) throws IllegalArgumentException
DateStructSet the day of the month component of the date, in the range 1 to 31.
setDay in interface DateStructday - Day of the month component of the date.IllegalArgumentException - Provided day value is outside the acceptable range.@UInt8 public final byte getMonth()
DateStructReturns the month component of the date, which is in the range 1 to 12.
getMonth in interface DateStructpublic final void setMonth(@UInt8 byte month) throws IllegalArgumentException
DateStructSet the month component of the date, which is in the range 1 to 12.
setMonth in interface DateStructmonth - Month component of the date.IllegalArgumentException - Provided month value is outside the acceptable range.@Int16 public final short getYear()
DateStructReturns the year component of the date.
getYear in interface DateStructpublic final void setYear(@Int16 short year) throws IllegalArgumentException
DateStructSets the year component of the date, in the range -9999 to 9999.
setYear in interface DateStructyear - Year component of the date.IllegalArgumentException - Year is outside the acceptable range.public final Calendar getDateValue()
Returns a copy of the Calendar value representing the
day given by this date.
getDateValue in interface DateStructpublic final void setDateValue(Calendar dateItem) throws NullPointerException, IllegalArgumentException
Set the Calendar value used internally to represent this
date value.
dateItem - Calendar value to use to set the date.NullPointerException - The given calendar value is null.IllegalArgumentExceptionpublic final String toString()
Formats the date value as a UTC date-only value. The format is
"yyyy-mm-dd", the year followed by the month followed by
the day of the month. Note that locale and timezone are not available
in a date structure.
toString in interface DateStructtoString in class ObjectForge.parseDate(String)public static final DateStructImpl parseFactory(String date) throws ParseException, NullPointerException, IllegalArgumentException
Create a new date structure value from a string representation of a date. The date
should be represented as the UTC portion of a date in the format
"yyyy-mm-dd".
Note that this method does not support the specification of timezone or dates earlier than 1AD.
date - Date value represented as a string.ParseException - Given string value cannot be parsed into a date structure as it
is in the wrong format.NullPointerException - The given string representation of a date is null.IllegalArgumentException - After successful parsing, the given date is not an
acceptable value.public final boolean equals(Object o)
Tests to see if this date structure has an equal value to the date structure passed in. Comparison is done based on year, month and day of month values only to remain compatible with the fields actually represented by AAF.
public final DateStruct clone()
DateStructCreate a cloned copy of this date value.
clone in interface DateStructclone in class Objectpublic static final void generateEmbeddableORM(Node parent, String namespace, String prefix)
(c)2007-2016 Richard Cartwright, all rights reserved. Licensed under Apache 2 license and subject to the AMWA IPR policy.