public class Date extends Date
Date
format.
Dates are represented in SQL as yyyy-MM-dd
. Note that this date
format only deals with year, month and day values. There are no values for
hours, minutes, seconds.
This is unlike the familiar java.util.Date
object, which also includes
values for hours, minutes, seconds, and milliseconds.
Time points are handled as millisecond values - milliseconds since the Epoch,
January 1st 1970, 00:00:00.000 GMT. Time values passed to the java.sql.Date
class are "normalized" to the time 00:00:00.000 GMT on the
date implied by the time value.
Constructor and Description |
---|
Date(int theYear,
int theMonth,
int theDay)
Deprecated.
Use the constructor
Date(long) . |
Date(long theDate)
Creates a date which corresponds to the day determined by the supplied
milliseconds time value
theDate . |
Modifier and Type | Method and Description |
---|---|
int |
getHours()
Deprecated.
This method is deprecated and must not be used. SQL
Date values do not have an hours component. |
int |
getMinutes()
Deprecated.
This method is deprecated and must not be used. SQL
Date values do not have a minutes component. |
int |
getSeconds()
Deprecated.
This method is deprecated and must not be used. SQL
Date values do not have a seconds component. |
void |
setHours(int theHours)
Deprecated.
This method is deprecated and must not be used. SQL
Date values do not have an hours component. |
void |
setMinutes(int theMinutes)
Deprecated.
This method is deprecated and must not be used. SQL
Date values do not have a minutes component. |
void |
setSeconds(int theSeconds)
Deprecated.
This method is deprecated and must not be used. SQL
Date values do not have a seconds component. |
void |
setTime(long theTime)
Sets this date to a date supplied as a milliseconds value.
|
String |
toString()
Produces a string representation of the date in SQL format
|
static Date |
valueOf(String dateString)
Creates a
Date from a string representation of a date in SQL
format. |
@Deprecated public Date(int theYear, int theMonth, int theDay)
Date(long)
.Date
object corresponding to the supplied year,
month and day.theYear
- the year, specified as the year minus 1900. Must be in the
range [0,8099]
.theMonth
- the month, specified as a number with 0 = January. Must be in
the range [0,11]
.theDay
- the day in the month. Must be in the range [1,31]
.public Date(long theDate)
theDate
.theDate
- a time value in milliseconds since the epoch - January 1 1970
00:00:00 GMT. The time value (hours, minutes, seconds,
milliseconds) stored in the Date
object is adjusted to
correspond to 00:00:00 GMT on the day determined by the supplied
time value.@Deprecated public int getHours()
Date
values do not have an hours component.Date
Date
object.getHours
in class Date
IllegalArgumentException
- if this method is called.@Deprecated public int getMinutes()
Date
values do not have a minutes component.Date
Date
object.getMinutes
in class Date
IllegalArgumentException
- if this method is called.@Deprecated public int getSeconds()
Date
values do not have a seconds component.Date
Date
object.getSeconds
in class Date
IllegalArgumentException
- if this method is called.@Deprecated public void setHours(int theHours)
Date
values do not have an hours component.Date
Date
object.setHours
in class Date
theHours
- the number of hours to set.IllegalArgumentException
- if this method is called.@Deprecated public void setMinutes(int theMinutes)
Date
values do not have a minutes component.Date
Date
object.setMinutes
in class Date
theMinutes
- the number of minutes to set.IllegalArgumentException
- if this method is called.@Deprecated public void setSeconds(int theSeconds)
Date
values do not have a seconds component.Date
Date
object.setSeconds
in class Date
theSeconds
- the number of seconds to set.IllegalArgumentException
- if this method is called.public void setTime(long theTime)
public String toString()
public static Date valueOf(String dateString)
Date
from a string representation of a date in SQL
format.dateString
- the string representation of a date in SQL format - " yyyy-MM-dd
".Date
object.IllegalArgumentException
- if the format of the supplied string does not match the SQL
format.