|
Media Authoring with Java API |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objecttv.amwa.maj.embeddable.DateStruct
public final class DateStruct
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
TimeStamp,
TimeStruct,
TypeDefinitionRecord.DateStruct,
Serialized Form| Constructor Summary | |
|---|---|
DateStruct()
Create a new date structure for the current date. |
|
DateStruct(byte day,
byte month,
short year)
Create a new date value using the given year, month and day of the month values. |
|
DateStruct(Calendar dateItem)
Create a new date structure from a Calendar value. |
|
| Method Summary | |
|---|---|
static DateStruct |
castFromInterface(DateStruct alien)
Create an instance of this date structure implementation using a possibly alien implementation that at least implements tv.amwa.maj.record.DateStruct. |
DateStruct |
clone()
Creates a cloned deep copy of this embeddable value. |
boolean |
equals(Object o)
Tests to see if this date structure has an equal value to the date structure passed in. |
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()
Returns a hash code value for this embeddable object. |
static DateStruct |
parseDateStruct(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 |
setPropertiesFromInterface(DateStruct castFrom)
Set the properties of this value from those available in the given value, which is specified by the date structure interface. |
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. |
| Methods inherited from class java.lang.Object |
|---|
getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DateStruct(@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 DateStruct(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 DateStruct()
Create a new date structure for the current date.
| Method Detail |
|---|
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.
public static final DateStruct castFromInterface(DateStruct alien)
throws NullPointerException
Create an instance of this date structure implementation using a possibly alien implementation that
at least implements tv.amwa.maj.record.DateStruct. If
the given value is an instance of this class, the value is returned directly, otherwise a new date
structure is constructed with an equivalent value to the given value.
alien - Object implementing DateStruct to
use to create an instance of this implementation from.
NullPointerException - The alien value argument is null.setPropertiesFromInterface(tv.amwa.maj.record.DateStruct)
public final void setPropertiesFromInterface(DateStruct castFrom)
throws NullPointerException
Set the properties of this value from those available in the given value, which is specified by the date structure interface.
castFrom - Value to extract properties from.
NullPointerException - The given value to use to set this value is null.castFromInterface(tv.amwa.maj.record.DateStruct)@UInt8 public final byte getDay()
DateStructReturns the day of the month component of the date.
getDay in interface DateStruct
public 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 DateStruct
public 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 DateStruct
public 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.
public 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 MAJCommontoString in class ObjectObject.toString()
public static final DateStruct parseDateStruct(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.
equals in interface MAJCommonequals in class Objecto - Object to test for equality with.
Object.equals(Object)public final int hashCode()
MAJCommonReturns a hash code value for this embeddable object.
hashCode in interface MAJCommonhashCode in class ObjectObject.hashCode()public final DateStruct clone()
MAJCommonCreates a cloned deep copy of this embeddable value. The clone will be initialized to have the same value as this value but exists independently from then on. Changes to this value will not effect the clone and changes to the clone will not effect this. MAJ API clones are true deep clones with no shared references to areas of memory within the original.
This method does not throw a CloneNotSupportedException as all
embeddable values must implement the Cloneable interface.
clone in interface MAJCommonclone in class ObjectObject.clone()
|
Media Authoring with Java API |
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||