# Date

public class **Date** extends [Date](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html)  
<br />

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 Constructor Summary

|---|---|
|   | [Date](https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html#Date(int,%20int,%20int))(int year, int month, int day) *This constructor is deprecated. instead use the constructor `Date(long date)`* |
|   | [Date](https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html#Date(long))(long date) Constructs a `Date` object using the given milliseconds time value. |

### Public Method Summary

|---|---|
| int | [getHours](https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html#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](https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html#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](https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html#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](https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html#setHours(int))(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](https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html#setMinutes(int))(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](https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html#setSeconds(int))(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](https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html#setTime(long))(long date) Sets an existing `Date` object using the given milliseconds time value. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html#toString())() Formats a date in the date escape format yyyy-mm-dd. |
| static [Date](https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html) | [valueOf](https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html#valueOf(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) s) Converts a string in JDBC date escape format to a `Date` value. |

### Inherited Method Summary

From class [java.util.Date](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html)

|---|---|
| static long | [UTC](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#UTC(int,%20int,%20int,%20int,%20int,%20int))(int year, int month, int date, int hrs, int min, int sec) *This method is deprecated. As of JDK version 1.1, replaced by `Calendar.set(year + 1900, month, date, hrs, min, sec)` or `GregorianCalendar(year + 1900, month, date, hrs, min, sec)`, using a UTC `TimeZone`, followed by `Calendar.getTime().getTime()`.* |
| boolean | [after](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#after(java.util.Date))([Date](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html) when) Tests if this date is after the specified date. |
| boolean | [before](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#before(java.util.Date))([Date](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html) when) Tests if this date is before the specified date. |
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#clone())() Return a copy of this object. |
| int | [compareTo](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#compareTo(java.util.Date))([Date](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html) anotherDate) Compares two Dates for ordering. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares two dates for equality. |
| int | [getDate](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#getDate())() *This method is deprecated. As of JDK version 1.1, replaced by `Calendar.get(Calendar.DAY_OF_MONTH)`.* |
| int | [getDay](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#getDay())() *This method is deprecated. As of JDK version 1.1, replaced by `Calendar.get(Calendar.DAY_OF_WEEK)`.* |
| int | [getHours](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#getHours())() *This method is deprecated. As of JDK version 1.1, replaced by `Calendar.get(Calendar.HOUR_OF_DAY)`.* |
| int | [getMinutes](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#getMinutes())() *This method is deprecated. As of JDK version 1.1, replaced by `Calendar.get(Calendar.MINUTE)`.* |
| int | [getMonth](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#getMonth())() *This method is deprecated. As of JDK version 1.1, replaced by `Calendar.get(Calendar.MONTH)`.* |
| int | [getSeconds](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#getSeconds())() *This method is deprecated. As of JDK version 1.1, replaced by `Calendar.get(Calendar.SECOND)`.* |
| long | [getTime](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#getTime())() Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object. |
| int | [getTimezoneOffset](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#getTimezoneOffset())() *This method is deprecated. As of JDK version 1.1, replaced by `-(Calendar.get(Calendar.ZONE_OFFSET) + Calendar.get(Calendar.DST_OFFSET)) / (60 * 1000)`.* |
| int | [getYear](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#getYear())() *This method is deprecated. As of JDK version 1.1, replaced by `Calendar.get(Calendar.YEAR) - 1900`.* |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#hashCode())() Returns a hash code value for this object. |
| static long | [parse](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#parse(java.lang.String))([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) s) *This method is deprecated. As of JDK version 1.1, replaced by `DateFormat.parse(String s)`.* |
| void | [setDate](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#setDate(int))(int date) *This method is deprecated. As of JDK version 1.1, replaced by `Calendar.set(Calendar.DAY_OF_MONTH, int date)`.* |
| void | [setHours](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#setHours(int))(int hours) *This method is deprecated. As of JDK version 1.1, replaced by `Calendar.set(Calendar.HOUR_OF_DAY, int hours)`.* |
| void | [setMinutes](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#setMinutes(int))(int minutes) *This method is deprecated. As of JDK version 1.1, replaced by `Calendar.set(Calendar.MINUTE, int minutes)`.* |
| void | [setMonth](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#setMonth(int))(int month) *This method is deprecated. As of JDK version 1.1, replaced by `Calendar.set(Calendar.MONTH, int month)`.* |
| void | [setSeconds](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#setSeconds(int))(int seconds) *This method is deprecated. As of JDK version 1.1, replaced by `Calendar.set(Calendar.SECOND, int seconds)`.* |
| void | [setTime](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#setTime(long))(long time) Sets this `Date` object to represent a point in time that is `time` milliseconds after January 1, 1970 00:00:00 GMT. |
| void | [setYear](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#setYear(int))(int year) *This method is deprecated. As of JDK version 1.1, replaced by `Calendar.set(Calendar.YEAR, year + 1900)`.* |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toGMTString](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#toGMTString())() *This method is deprecated. As of JDK version 1.1, replaced by `DateFormat.format(Date date)`, using a GMT `TimeZone`.* |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toLocaleString](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#toLocaleString())() *This method is deprecated. As of JDK version 1.1, replaced by `DateFormat.format(Date date)`.* |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html#toString())() Converts this `Date` object to a `String` of the form: > ``` >  dow mon dd hh:mm:ss zzz yyyy > ``` where: - dow is the day of the week (Sun, Mon, Tue, Wed, Thu, Fri, Sat). |

From class [java.lang.Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html)

|---|---|
| [Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) | [clone](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#clone())() Creates and returns a copy of this `Object`. |
| boolean | [equals](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#equals(java.lang.Object))([Object](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html) obj) Compares this instance with the specified object and indicates if they are equal. |
| void | [finalize](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#finalize())() Invoked when the garbage collector has detected that this instance is no longer reachable. |
| final [Class](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html)\<?\> | [getClass](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#getClass())() Returns the unique instance of `https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Class.html` that represents this object's class. |
| int | [hashCode](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#hashCode())() Returns an integer hash code for this object. |
| final void | [notify](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notify())() Causes a thread which is waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| final void | [notifyAll](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#notifyAll())() Causes all threads which are waiting on this object's monitor (by means of calling one of the `wait()` methods) to be woken up. |
| [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) | [toString](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#toString())() Returns a string containing a concise, human-readable description of this object. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long,%20int))(long timeout, int nanos) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait(long))(long timeout) Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object or until the specified timeout expires. |
| final void | [wait](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Object.html#wait())() Causes the calling thread to wait until another thread calls the `notify()` or `notifyAll()` method of this object. |

From interface [java.lang.Comparable](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable.html)

|---|---|
| abstract int | [compareTo](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/Comparable.html#compareTo(T))([Date](https://developers.google.com/j2objc/javadoc/jre/reference/java/util/Date.html) o) Compares this object with the specified object for order. |

## Public Constructors

#### public
**Date**
(int year, int month, int day)


**This constructor is deprecated.**   
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 | the year minus 1900; must be 0 to 8099. (Note that 8099 is 9999 minus 1900.) |
| month | 0 to 11 |
| day | 1 to 31 |
|---|---|

#### public
**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 | 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. |
|---|---|

## Public Methods

#### public 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

- the hour represented by this date.

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if this method is invoked |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html#setHours(int)`

#### public 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

- the number of minutes past the hour represented by this date.

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if this method is invoked |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html#setMinutes(int)`

#### public 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

- the number of seconds past the minute represented by this date.

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if this method is invoked |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html#setSeconds(int)`

#### public 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 | the hour value. |
|---|---|

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if this method is invoked |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html#getHours()`

#### public 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 | the value of the minutes. |
|---|---|

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if this method is invoked |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html#getMinutes()`

#### public 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 | the seconds value. |
|---|---|

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if this method is invoked |
|---|---|

##### See Also

- `https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html#getSeconds()`

#### public 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 | 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. |
|---|---|

#### public [String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html)
**toString**
()

Formats a date in the date escape format yyyy-mm-dd.

<br />

##### Returns

- a String in yyyy-mm-dd format

#### public static [Date](https://developers.google.com/j2objc/javadoc/jre/reference/java/sql/Date.html)
**valueOf**
([String](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/String.html) s)

Converts a string in JDBC date escape format to
a `Date` value.

##### Parameters

| s | 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

- a `java.sql.Date` object representing the given date

##### Throws

| [IllegalArgumentException](https://developers.google.com/j2objc/javadoc/jre/reference/java/lang/IllegalArgumentException.html) | if the date given is not in the JDBC date escape format (yyyy-\[m\]m-\[d\]d) |
|---|---|