This class provides the Java binding for the XML schema type
time as specified in Section 3.2.25 of XML Schema Part 2:
Datatypes.
time represents a specific instant of a time that recurs every
day.
Instances of this type can be constructed from valid instances
of time strings and java.sql.Time.
public Object |
-
clone ()
- Returns a copy of this Time.
|
public int |
-
compareTo (Time anotherTime)
- Compares this Time to another Time object (represented in the
same time zone) in their canonical representation.
|
public int |
-
compareTo (Object anotherObject)
- Compares this Time with another object.
|
public static Time |
-
createTime ()
- Returns a Time instance for the current
time at the local time zone.
|
public static Time |
-
createTime (String time)
Given a string of the form hh:mm:ss.sss, returns a
Time instance.
|
public static Time |
-
createTime (Date date)
- Given a java.util.Date, returns a Time instance.
|
public static Time |
-
createTime (Date date)
- Given a java.sql.Date, returns a Time instance.
|
public static Time |
-
createTime (Timestamp timestamp)
- Given a java.util.Timestamp, returns a Time instance.
|
public static Time |
-
createTime (double time)
- Given the value of milliseconds since the 00:00:00 GMT, returns
a Time.
|
public int |
-
getHour ()
- Returns the hour (hh) field
|
public int |
-
getMinute ()
- Returns the minute (mm) field
|
public double |
-
getSecond ()
- Returns the second (ss.sss) field
|
public double |
-
getTime ()
- Returns the value of milliseconds since 00:00:00 GMT
represented by this time instant object.
|
public TimeZone |
-
getTimeZone ()
- Returns the time zone
|
public boolean |
-
isTimeZoneUTC ()
- Returns true if the time instant is based on UTC
|
public void |
-
setHour (int hour)
- Sets the hour (hh) field
|
public void |
-
setMinute (int minute)
- Sets the minute (mm) field
|
public void |
-
setSecond (double second)
- Sets the second (ss.sss) field
|
public void |
-
setTimeZone (int zoneHour, int zoneMinute)
- Sets the time zone
|
public void |
-
setTimeZone (TimeZone timeZone)
- Sets the time zone
|
public Time |
-
toSQLTime ()
Returns a java.sql.Date equivalent.
|
public String |
-
toString ()
Returns a XML schema compliant time string.
|
public Time |
-
toUTC ()
- Offsets the current time instant to UTC.
|
hh:ss>) are equal.
Parameters
-
anotherTime
- another Time object to be compared.
Returns
- the value 0 if the argument Time is equal to this Time;
a value less than 0 if this Time is before the Time argument;
and a value greater than 0 if this Time is after the Time
argument.
compareTo(Object) Method
public int compareTo(Object
anotherObject)
Compares this Time with another object. If the other
object is a Time, this method behaves like
compareTo(Time). Otherwise, it throws a
ClassCastException.
Parameters
-
anotherObject
- the object to be compared
Returns
- the value 0 if the argument Time is equal to
this Time; a value less than 0 if this Time is
before the Time argument; and a value greater than 0 if
this Time is after the Time argument.
createTime() Method
public static Time
createTime()
Returns a Time instance for the current
time at the local time zone.
Returns
- instance of Time
createTime(String) Method
public static Time
createTime(String
time)
throws ParseException
Given a string of the form hh:mm:ss.sss, returns a
Time instance.
The argument may optionally contain the time zone.
Parameters
-
time
- representation of XML schema time
Returns
- instance of Time
Exceptions
-
ParseException
createTime(Date) Method
public static Time
createTime(Date
date)
Given a java.util.Date, returns a Time instance.
Parameters
-
date
- date
Returns
- instance of Time
createTime(Date) Method
public static Time
createTime(Date
date)
Given a java.sql.Date, returns a Time instance.
Parameters
-
date
- date
Returns
- instance of Time
createTime(Timestamp) Method
public static Time
createTime(Timestamp
timestamp)
Given a java.util.Timestamp, returns a Time instance.
Parameters
-
timestamp
- timestamp
Returns
- instance of Time
createTime(double) Method
public static Time
createTime(double time)
Given the value of milliseconds since the 00:00:00 GMT, returns
a Time.
Parameters
-
time
- value of milliseconds since 00:00:00 GMT
Returns
- instance of Time
getHour() Method
public int getHour()
Returns the hour (hh) field
Returns
- the hour
getMinute() Method
public int getMinute()
Returns the minute (mm) field
Returns
- the minute
getSecond() Method
public double getSecond()
Returns the second (ss.sss) field
Returns
- the integer part of second
getTime() Method
public double getTime()
Returns the value of milliseconds since 00:00:00 GMT
represented by this time instant object.
Returns
- value of milliseconds
getTimeZone() Method
public TimeZone
getTimeZone()
Returns the time zone
Returns
- timeZone the time zone
isTimeZoneUTC() Method
public boolean isTimeZoneUTC()
Returns true if the time instant is based on UTC
Returns
- true if the time instant is based on UTC
setHour(int) Method
public void setHour(int hour)
throws IllegalArgumentException
Sets the hour (hh) field
Parameters
-
hour
- the hour
Exceptions
-
IllegalArgumentException
- thrown when the hour argument is illegal
setMinute(int) Method
public void setMinute(int minute)
throws IllegalArgumentException
Sets the minute (mm) field
Parameters
-
minute
- the minute
Exceptions
-
IllegalArgumentException
- thrown when the minute argument is illegal
setSecond(double) Method
public void setSecond(double second)
throws IllegalArgumentException
Sets the second (ss.sss) field
Parameters
-
second
- the second
Exceptions
-
IllegalArgumentException
- thrown when the second argument is illegal
setTimeZone(int, int) Method
public void setTimeZone(int zoneHour,
int zoneMinute)
Sets the time zone
Parameters
-
zoneHour
- the hour field of timeZone. Can be negative to
indicate negative offset.
-
zoneMinute
- the minute field of timeZone
setTimeZone(TimeZone) Method
public void setTimeZone(TimeZone
timeZone)
Sets the time zone
Parameters
-
timeZone
- an instance java.util.TimeZone
toSQLTime() Method
public Time
toSQLTime()
Returns a java.sql.Date
equivalent. Note that
this operation excludes any timezone.
Returns
- java.sql.Date
toString() Method
public String
toString()
Returns a XML schema compliant time string.
The method does not guarantee
Time.createTime(_string).toString().equals(_string)
to be true.
-
Overrides
-
Object.toString()
Returns
- string value
toUTC() Method
public Time
toUTC()
Offsets the current time instant to UTC.
Returns
- instance of TimeInstant offset to UTC