|
© 2005 BEA Systems, Inc. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bea.p13n.xml.schema.TimeInstant
This class provides the Java binding for the XML schema type timeInstant as specified in Section 3.2.24 of XML Schema Part 2: Datatypes.
timeInstant represents a specific instant of a time. The value space of timeInstant is the space of combinations of date and time of day values as defined in ISO 8601.
Time zone specification is not optional.
Example: 2001-01-18T09:00:00.0005Z
.
In this representation, one can represent arbitrary precision
seconds. Timezone offsets can be represented with the optional zone
indicator Z
for UTC or one of -hh::mm
or
+hh:mm
to indicate the difference from UTC.
Instances of this type can be constructed from valid instances of timeInstant strings, java.util.Date, java.sql.Date, and java.util.Timestamp.
As the XML Schema specification allows arbitrary precision
seconds representation, this class preserves the precision of
seconds when instances of this class are created from a timeInstant
string. However, such precision may be lost when instances of
java.util.Date, java.sql.Date or java.sql.Timestamp are obtained
from an instance of TimeInstant
.
long
and
double
respectively in the Java programming
language.java.util.Date
, java.sql.Date
and
java.sql.Timestamp
) can not represent values of
years beyond the range of -2147483648 to 2147483647, this class
chooses a higher precision for these values. The same applies to
seconds. Therefore, any conversion between instances of
TimeDuration
and instances of
java.util.Date
, java.sql.Date
and
java.sql.Timestamp
may be subjected rounding and
loss of information. Design Note: Although a timeInstant is a derived type (derived from recurringDuration), there is no inheritance association between TimeInstant and TimeDuration. From the point of XML Schema, a recurringDuration is a more general type, and all the derived types (including timeInstant, time, timePeriod, recurringDate, and recurringDay) can be created by restricting the values facets of recurringDuration. For instance, a timeInstant can be created by restricting both the duration and period facets to be P0Y.
However, in this design, the same notion is not applied to the corresponding Java types. This is to prevent extraneous methods appearing on classes for derived types. For instance, by not having a specialization association between TimeInstant and RecurringDuration, this design prevents methods such as getDuration() from the TimeInstant class. The design instead relies on delegation.
Constructor Summary | |
protected |
TimeInstant()
Constructs a new TimeInstant instance corresponding to the current time in the local time zone. |
Method Summary | |
Object |
clone()
Returns a copy of this TimeInstant. |
int |
compareTo(Date date)
Compares this TimeInstant to a Date object in their canonical representation. |
int |
compareTo(Object anotherObject)
Compares this TimeInstant with another object. |
int |
compareTo(Time time)
Compares this TimeInstant to a Time object in their canonical representation. |
int |
compareTo(TimeInstant anotherTimeInstant)
Compares this TimeInstant to another TimeInstant object (represented in the same time zone) in their canonical representation. |
static TimeInstant |
createTimeInstant()
Returns a TimeInstant instance for the current time at the local time zone. |
static TimeInstant |
createTimeInstant(Calendar c)
Given a java.util.Calendar, returns a TimeInstant instance. |
static TimeInstant |
createTimeInstant(Date date)
Given a java.util.Date, returns a TimeInstant instance. |
static TimeInstant |
createTimeInstant(Date date)
Given a java.sql.Date, returns a TimeInstant instance. |
static TimeInstant |
createTimeInstant(double time)
Given the value of milliseconds since January 1, 1970, 00:00:00 GMT, returns a TimeInstant. |
static TimeInstant |
createTimeInstant(long time)
Given the value of milliseconds since January 1, 1970, 00:00:00 GMT, returns a TimeInstant. |
static TimeInstant |
createTimeInstant(String timeInstant)
Given a string, returns a TimeInstant instance. |
static TimeInstant |
createTimeInstant(Timestamp timestamp)
Given a java.util.Timestamp, returns a TimeInstant instance. |
boolean |
equals(Object object)
Indicates whether some other object is "equal to" this one. |
Calendar |
getCalendar()
Returns the Calendar representation of this class |
int |
getCalendarYear()
Get the Calendar year |
long |
getCentury()
Returns the century (CC) field |
int |
getDay()
Returns the day (DD) of the month field |
int |
getEra()
Returns the era (+/-) |
int |
getHour()
Returns the hour (hh) field |
int |
getMilliSeconds()
Get the milliseconds portion of the second field. |
int |
getMinute()
Returns the minute (mm) field |
int |
getMonth()
Returns the month (MM) field. |
double |
getSecond()
Returns the second (ss.sss) field with the milliseconds represented as a fraction of the second. |
int |
getSecondAsInt()
Returns the integer part of the second field. |
double |
getTime()
Returns the value of milliseconds since January 1, 1970, 00:00:00 GMT represented by this time instant object. |
TimeZone |
getTimeZone()
Returns the time zone |
long |
getYear()
Deprecated. Use int getCalendarYear() |
int |
getZoneHour()
Returns the hour field of time zone |
int |
getZoneMinute()
Returns the minute field of time zone |
boolean |
isTimeZoneUTC()
Returns true if the time instant is based on UTC |
TimeInstant |
offset(TimeDuration timeDuration)
Creates an offset of this TimeInstant with a given TimeDuration. |
void |
setCalendarYear(int year)
Sets the year (CCYY) field |
void |
setCentury(long century)
Sets the century (CC) field |
void |
setDay(int day)
Sets the day (DD) of the month field |
void |
setEra(int era)
Sets the era (+/-) |
void |
setHour(int hour)
Sets the hour (hh) field |
void |
setMilliSecond(int msec)
Sets the milliseconds field as an integer |
void |
setMinute(int minute)
Sets the minute (mm) field |
void |
setMonth(int month)
Sets the month (MM) field. |
void |
setSecond(double second)
Sets the second field in a fractional format |
void |
setSecond(int second)
Sets the second field as an integer |
void |
setTimeZone(int zoneHour,
int zoneMinute)
Sets the time zone |
void |
setTimeZone(TimeZone timeZone)
Sets the time zone |
void |
setYear(long year)
Deprecated. Use setCalendarYear(int year) |
void |
setYear(long century,
int year)
Deprecated. Use setCalendarYear(int year) , eg, setCalendarYear(2004) |
Date |
toDate()
Returns java.util.Date representation of timeInstant. |
Date |
toDate(Calendar calendarIn)
|
TimeInstant |
toLocal()
Offsets the current time instant to the local time zone. |
Date |
toSQLDate()
Returns java.sql.Date representation of timeInstant. |
String |
toString()
Returns a XML schema compliant timeInstant string. |
Timestamp |
toTimestamp()
Returns java.sql.Timestamp representation of timeInstant. |
TimeInstant |
toUTC()
Offsets the current time instant to UTC. |
Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
protected TimeInstant()
Method Detail |
public Object clone()
public int compareTo(Date date)
date
- the Date object to be compared.
IllegalArgumentException
- thrown when the argument is
represented in a different time zone from the current time
instant.public int compareTo(Object anotherObject)
compareTo
in interface Comparable
anotherObject
- the object to be compared
ClassCastException
- thrown if the argument is not an
instance of TimeInstant.public int compareTo(Time time)
time
- the Time object to be compared.
IllegalArgumentException
- thrown when the argument is
represented in a different time zone from the current time
instant.public int compareTo(TimeInstant anotherTimeInstant)
anotherTimeInstant
- another TimeInstant object to be compared.
IllegalArgumentException
- thrown when the argument is
represented in a different time zone from the current time
instant.public static TimeInstant createTimeInstant()
public static TimeInstant createTimeInstant(Calendar c)
public static TimeInstant createTimeInstant(Date date)
date
- date
public static TimeInstant createTimeInstant(Date date)
date
- date
public static TimeInstant createTimeInstant(double time)
time
- value of milliseconds since January 1, 1970, 00:00:00 GMT
public static TimeInstant createTimeInstant(long time)
time
- value of milliseconds since January 1, 1970, 00:00:00 GMT
public static TimeInstant createTimeInstant(String timeInstant) throws ParseException
timeInstant
- representation of XML schema timeInstant
ParseException
- thrown due to illegal string argumentpublic static TimeInstant createTimeInstant(Timestamp timestamp)
timestamp
- timestamp
public boolean equals(Object object)
object
- the reference object with which to compare.
public Calendar getCalendar()
public int getCalendarYear()
public long getCentury()
public int getDay()
public int getEra()
public int getHour()
public int getMilliSeconds()
public int getMinute()
public int getMonth()
public double getSecond()
public int getSecondAsInt()
public double getTime()
public TimeZone getTimeZone()
public long getYear()
public int getZoneHour()
public int getZoneMinute()
public boolean isTimeZoneUTC()
public TimeInstant offset(TimeDuration timeDuration)
Creates an offset of this TimeInstant with a given TimeDuration.
Note: This implementation does not guarantee the precision beyond those values representable by java.util.Calendar.
timeDuration
- offset time duration
public void setCalendarYear(int year)
year
- - the year (CCYY)public void setCentury(long century)
century
- the century
IllegalArgumentException
- thrown when the century and
year arguments are illegalpublic void setDay(int day)
day
- the day of the month
IllegalArgumentException
- thrown when the date argument is illegalpublic void setEra(int era)
era
- the era (+/-)public void setHour(int hour) throws IllegalArgumentException
hour
- the hour
IllegalArgumentException
- thrown when the hour argument is illegalpublic void setMilliSecond(int msec) throws IllegalArgumentException
IllegalArgumentException
- thrown when the second argument is illegalpublic void setMinute(int minute) throws IllegalArgumentException
minute
- the minute
IllegalArgumentException
- thrown when the minute argument is illegalpublic void setMonth(int month) throws IllegalArgumentException
month
- the month (MM)
IllegalArgumentException
- thrown when the month argument is illegalpublic void setSecond(double second) throws IllegalArgumentException
IllegalArgumentException
- thrown when the second argument is illegalpublic void setSecond(int second) throws IllegalArgumentException
second
- the second
IllegalArgumentException
- thrown when the second argument is illegalpublic void setTimeZone(int zoneHour, int zoneMinute)
zoneHour
- the hour field of timeZone. Can be negative to
indicate negative offset.zoneMinute
- the minute field of timeZonepublic void setTimeZone(TimeZone timeZone)
timeZone
- an instance java.util.TimeZonepublic void setYear(long year)
year
- - the year (CCYY)public void setYear(long century, int year) throws IllegalArgumentException
century
- the century (CC)year
- the year (YY)
IllegalArgumentException
- thrown when the century and
year arguments are illegalpublic Date toDate()
public Date toDate(Calendar calendarIn)
public TimeInstant toLocal()
Offsets the current time instant to the local time zone.
Note: This implementation does not guarantee the precision beyond those values representable by java.util.Calendar.
public Date toSQLDate()
public String toString()
Returns a XML schema compliant timeInstant string.
This method uses the following rules:
The above rules imply that this method does not guarantee TimeInstant.createTimeInstant(_string).toString().equals(_string) to be true.
public Timestamp toTimestamp()
public TimeInstant toUTC()
Offsets the current time instant to UTC.
Note: This implementation does not guarantee the precision beyond those values representable by java.util.Calendar.
|
© 2005 BEA Systems, Inc. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |