public class Time extends Date
A thin wrapper around the java.util.Date
class that allows the JDBC
API to identify this as an SQL TIME
value. The Time
class adds formatting and
parsing operations to support the JDBC escape syntax for time
values.
The date components should be set to the "zero epoch" value of January 1, 1970 and should not be accessed.
Constructor and Description |
---|
Time(int hour,
int minute,
int second)
Deprecated.
Use the constructor that takes a milliseconds value
in place of this constructor
|
Time(long time)
Constructs a
Time object using a milliseconds time value. |
Modifier and Type | Method and Description |
---|---|
int |
getDate()
Deprecated.
This method is deprecated and should not be used because SQL
TIME
values do not have a date component. |
int |
getDay()
Deprecated.
This method is deprecated and should not be used because SQL
TIME
values do not have a day component. |
int |
getMonth()
Deprecated.
This method is deprecated and should not be used because SQL
TIME
values do not have a month component. |
int |
getYear()
Deprecated.
This method is deprecated and should not be used because SQL
TIME
values do not have a year component. |
void |
setDate(int i)
Deprecated.
This method is deprecated and should not be used because SQL
TIME
values do not have a date component. |
void |
setMonth(int i)
Deprecated.
This method is deprecated and should not be used because SQL
TIME
values do not have a month component. |
void |
setTime(long time)
Sets a
Time object using a milliseconds time value. |
void |
setYear(int i)
Deprecated.
This method is deprecated and should not be used because SQL
TIME
values do not have a year component. |
String |
toString()
Formats a time in JDBC time escape format.
|
static Time |
valueOf(String s)
Converts a string in JDBC time escape format to a
Time value. |
after, before, clone, compareTo, equals, getHours, getMinutes, getSeconds, getTime, getTimezoneOffset, hashCode, parse, setHours, setMinutes, setSeconds, toGMTString, toLocaleString, UTC
@Deprecated public Time(int hour, int minute, int second)
Time
object initialized with the
given values for the hour, minute, and second.
The driver sets the date components to January 1, 1970.
Any method that attempts to access the date components of a
Time
object will throw a
java.lang.IllegalArgumentException
.
The result is undefined if a given argument is out of bounds.
hour
- 0 to 23minute
- 0 to 59second
- 0 to 59public Time(long time)
Time
object using a milliseconds time value.time
- milliseconds since January 1, 1970, 00:00:00 GMT;
a negative number is milliseconds before
January 1, 1970, 00:00:00 GMTpublic void setTime(long time)
Time
object using a milliseconds time value.public static Time valueOf(String s)
Time
value.s
- time in format "hh:mm:ss"Time
objectpublic String toString()
toString
in class Date
String
in hh:mm:ss formatDate.toLocaleString()
,
Date.toGMTString()
@Deprecated public int getYear()
TIME
values do not have a year component.Date
Date
object, as interpreted in the local
time zone.getYear
in class Date
IllegalArgumentException
- if this
method is invokedsetYear(int)
@Deprecated public int getMonth()
TIME
values do not have a month component.Date
0
and 11
,
with the value 0
representing January.getMonth
in class Date
IllegalArgumentException
- if this
method is invokedsetMonth(int)
@Deprecated public int getDay()
TIME
values do not have a day component.Date
getDay
in class Date
IllegalArgumentException
- if this
method is invokedCalendar
@Deprecated public int getDate()
TIME
values do not have a date component.Date
1
and 31
representing the day of the month that contains or begins with the
instant in time represented by this Date object, as
interpreted in the local time zone.getDate
in class Date
IllegalArgumentException
- if this
method is invokedsetDate(int)
@Deprecated public void setYear(int i)
TIME
values do not have a year component.Date
Date
object is modified so
that it represents a point in time within the specified year,
with the month, date, hour, minute, and second the same as
before, as interpreted in the local time zone. (Of course, if
the date was February 29, for example, and the year is set to a
non-leap year, then the new date will be treated as if it were
on March 1.)setYear
in class Date
i
- the year value.IllegalArgumentException
- if this
method is invokedgetYear()
@Deprecated public void setMonth(int i)
TIME
values do not have a month component.Date
setMonth
in class Date
i
- the month value between 0-11.IllegalArgumentException
- if this
method is invokedgetMonth()
@Deprecated public void setDate(int i)
TIME
values do not have a date component.Date
setDate
in class Date
i
- the day of the month value between 1-31.IllegalArgumentException
- if this
method is invokedgetDate()