|
© 2002 BEA Systems, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | 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. |
Method Summary | |
java.lang.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(java.lang.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(java.util.Calendar calendar)
Given a java.util.Calendar, returns a TimeInstant instance. |
static TimeInstant |
createTimeInstant(java.util.Date date)
Given a java.util.Date, returns a TimeInstant instance. |
static TimeInstant |
createTimeInstant(java.sql.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(java.lang.String timeInstant)
Given a string, returns a TimeInstant instance. |
static TimeInstant |
createTimeInstant(java.sql.Timestamp timestamp)
Given a java.util.Timestamp, returns a TimeInstant instance. |
boolean |
equals(java.lang.Object object)
Indicates whether some other object is "equal to" this one. |
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 |
getMinute()
Returns the minute (mm) field |
int |
getMonth()
Returns the month (MM) field |
double |
getSecond()
Returns the second (ss.sss) field |
double |
getTime()
Returns the value of milliseconds since January 1, 1970, 00:00:00 GMT represented by this time instant object. |
java.util.TimeZone |
getTimeZone()
Returns the time zone |
long |
getYear()
Returns the year (CCYY) field |
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 |
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 |
setMinute(int minute)
Sets the minute (mm) field |
void |
setMonth(int month)
Sets the month (MM) field |
void |
setSecond(double second)
Sets the second (ss.sss) field |
void |
setTimeZone(int zoneHour,
int zoneMinute)
Sets the time zone |
void |
setTimeZone(java.util.TimeZone timeZone)
Sets the time zone |
void |
setYear(long year)
Sets the year (CCYY) field |
void |
setYear(long century,
int year)
Sets the year (CCYY) field |
java.util.Date |
toDate()
Returns java.util.Date representation of timeInstant. |
TimeInstant |
toLocal()
Offsets the current time instant to the local time zone. |
java.sql.Date |
toSQLDate()
Returns java.sql.Date representation of timeInstant. |
java.lang.String |
toString()
Returns a XML schema compliant timeInstant string. |
java.sql.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 static TimeInstant createTimeInstant()
public static TimeInstant createTimeInstant(java.lang.String timeInstant) throws java.text.ParseException
String
- representation of XML schema timeInstantpublic static TimeInstant createTimeInstant(java.util.Date date)
date
- datepublic static TimeInstant createTimeInstant(java.sql.Date date)
date
- datepublic static TimeInstant createTimeInstant(java.sql.Timestamp timestamp)
timestamp
- timestamppublic static TimeInstant createTimeInstant(java.util.Calendar calendar)
calendar
- calendarpublic static TimeInstant createTimeInstant(double time)
time
- value of milliseconds since January 1, 1970, 00:00:00 GMTpublic java.lang.Object clone()
public int compareTo(TimeInstant anotherTimeInstant)
anotherTimeInstant
- another TimeInstant object to be compared.public int compareTo(Date date)
date
- the Date object to be compared.public int compareTo(Time time)
time
- the Time object to be compared.public int compareTo(java.lang.Object anotherObject)
object
- the object to be comparedpublic 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 durationpublic int getEra()
public void setEra(int era)
era
- the era (+/-)public long getCentury()
public void setCentury(long century)
century
- the centurypublic long getYear()
public void setYear(long century, int year) throws java.lang.IllegalArgumentException
century
- the century (CC)year
- the year (YY)public void setYear(long year)
the
- year (CCYY)public int getMonth()
public void setMonth(int month) throws java.lang.IllegalArgumentException
month
- the month (MM)public int getDay()
public void setDay(int day)
date
- the day of the monthpublic int getHour()
public void setHour(int hour) throws java.lang.IllegalArgumentException
hour
- the hourpublic int getMinute()
public void setMinute(int minute) throws java.lang.IllegalArgumentException
minute
- the minutepublic double getSecond()
public void setSecond(double second) throws java.lang.IllegalArgumentException
second
- the secondpublic 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 int getZoneHour()
public int getZoneMinute()
public void setTimeZone(java.util.TimeZone timeZone)
timeZone
- an instance java.util.TimeZonepublic java.util.TimeZone getTimeZone()
public boolean isTimeZoneUTC()
public java.lang.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 java.util.Date toDate()
public java.sql.Date toSQLDate()
public java.sql.Timestamp toTimestamp()
public double getTime()
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.
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 boolean equals(java.lang.Object object)
object
- the reference object with which to compare.
|
© 2002 BEA Systems, Inc. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |