public
class
Date
extends Date
java.lang.Object | ||
↳ | java.util.Date | |
↳ | java.sql.Date |
A thin wrapper around a millisecond value that allows
JDBC to identify this as an SQL DATE
value. A
milliseconds value represents the number of milliseconds that
have passed since January 1, 1970 00:00:00.000 GMT.
To conform with the definition of SQL DATE
, the
millisecond values wrapped by a java.sql.Date
instance
must be 'normalized' by setting the
hours, minutes, seconds, and milliseconds to zero in the particular
time zone with which the instance is associated.
Public constructors | |
---|---|
Date(int year, int month, int day)
This constructor was deprecated
in API level 1.
instead use the constructor |
|
Date(long date)
Constructs a |
Public methods | |
---|---|
int
|
getHours()
This method is deprecated. This method is deprecated and should not be used because SQL Date values do not have a time component. |
int
|
getMinutes()
This method is deprecated. This method is deprecated and should not be used because SQL Date values do not have a time component. |
int
|
getSeconds()
This method is deprecated. This method is deprecated and should not be used because SQL Date values do not have a time component. |
void
|
setHours(int i)
This method is deprecated. This method is deprecated and should not be used because SQL Date values do not have a time component. |
void
|
setMinutes(int i)
This method is deprecated. This method is deprecated and should not be used because SQL Date values do not have a time component. |
void
|
setSeconds(int i)
This method is deprecated. This method is deprecated and should not be used because SQL Date values do not have a time component. |
void
|
setTime(long date)
Sets an existing |
String
|
toString()
Formats a date in the date escape format yyyy-mm-dd. |
static
Date
|
valueOf(String s)
Converts a string in JDBC date escape format to
a |
Inherited methods | |
---|---|
From
class
java.util.Date
| |
From
class
java.lang.Object
| |
From
interface
java.lang.Comparable
|
Date (int year, int month, int day)
This constructor was deprecated
in API level 1.
instead use the constructor Date(long date)
Constructs a Date
object initialized with the given
year, month, and day.
The result is undefined if a given argument is out of bounds.
Parameters | |
---|---|
year |
int :
the year minus 1900; must be 0 to 8099. (Note that
8099 is 9999 minus 1900.) |
month |
int :
0 to 11 |
day |
int :
1 to 31 |
Date (long date)
Constructs a Date
object using the given milliseconds
time value. If the given milliseconds value contains time
information, the driver will set the time components to the
time in the default time zone (the time zone of the Java virtual
machine running the application) that corresponds to zero GMT.
Parameters | |
---|---|
date |
long :
milliseconds since January 1, 1970, 00:00:00 GMT not
to exceed the milliseconds representation for the year 8099.
A negative number indicates the number of milliseconds
before January 1, 1970, 00:00:00 GMT.
|
int getHours ()
This method is deprecated.
This method is deprecated and should not be used because SQL Date
values do not have a time component.
Returns the hour represented by this Date object. The returned value is a number (0 through 23) representing the hour within the day that contains or begins with the instant in time represented by this Date object, as interpreted in the local time zone.
Returns | |
---|---|
int |
the hour represented by this date. |
Throws | |
---|---|
IllegalArgumentException |
if this method is invoked |
See also:
int getMinutes ()
This method is deprecated.
This method is deprecated and should not be used because SQL Date
values do not have a time component.
Returns the number of minutes past the hour represented by this date,
as interpreted in the local time zone.
The value returned is between 0
and 59
.
Returns | |
---|---|
int |
the number of minutes past the hour represented by this date. |
Throws | |
---|---|
IllegalArgumentException |
if this method is invoked |
See also:
int getSeconds ()
This method is deprecated.
This method is deprecated and should not be used because SQL Date
values do not have a time component.
Returns the number of seconds past the minute represented by this date.
The value returned is between 0
and 61
. The
values 60
and 61
can only occur on those
Java Virtual Machines that take leap seconds into account.
Returns | |
---|---|
int |
the number of seconds past the minute represented by this date. |
Throws | |
---|---|
IllegalArgumentException |
if this method is invoked |
See also:
void setHours (int i)
This method is deprecated.
This method is deprecated and should not be used because SQL Date
values do not have a time component.
Sets the hour of this Date object to the specified value. This Date object is modified so that it represents a point in time within the specified hour of the day, with the year, month, date, minute, and second the same as before, as interpreted in the local time zone.
Parameters | |
---|---|
i |
int :
the hour value. |
Throws | |
---|---|
IllegalArgumentException |
if this method is invoked |
See also:
void setMinutes (int i)
This method is deprecated.
This method is deprecated and should not be used because SQL Date
values do not have a time component.
Sets the minutes of this Date object to the specified value. This Date object is modified so that it represents a point in time within the specified minute of the hour, with the year, month, date, hour, and second the same as before, as interpreted in the local time zone.
Parameters | |
---|---|
i |
int :
the value of the minutes. |
Throws | |
---|---|
IllegalArgumentException |
if this method is invoked |
See also:
void setSeconds (int i)
This method is deprecated.
This method is deprecated and should not be used because SQL Date
values do not have a time component.
Sets the seconds of this Date to the specified value. This Date object is modified so that it represents a point in time within the specified second of the minute, with the year, month, date, hour, and minute the same as before, as interpreted in the local time zone.
Parameters | |
---|---|
i |
int :
the seconds value. |
Throws | |
---|---|
IllegalArgumentException |
if this method is invoked |
See also:
void setTime (long date)
Sets an existing Date
object
using the given milliseconds time value.
If the given milliseconds value contains time information,
the driver will set the time components to the
time in the default time zone (the time zone of the Java virtual
machine running the application) that corresponds to zero GMT.
Parameters | |
---|---|
date |
long :
milliseconds since January 1, 1970, 00:00:00 GMT not
to exceed the milliseconds representation for the year 8099.
A negative number indicates the number of milliseconds
before January 1, 1970, 00:00:00 GMT.
|
String toString ()
Formats a date in the date escape format yyyy-mm-dd.
Returns | |
---|---|
String |
a String in yyyy-mm-dd format |
Date valueOf (String s)
Converts a string in JDBC date escape format to
a Date
value.
Parameters | |
---|---|
s |
String :
a String object representing a date in
in the format "yyyy-[m]m-[d]d". The leading zero for mm
and dd may also be omitted. |
Returns | |
---|---|
Date |
a java.sql.Date object representing the
given date |
Throws | |
---|---|
IllegalArgumentException |
if the date given is not in the JDBC date escape format (yyyy-[m]m-[d]d) |