public class

Date

extends Date
java.lang.Object
   ↳ java.util.Date
     ↳ java.sql.Date

Class Overview

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.

Summary

Public Constructors
Date(int year, int month, int day)
This constructor is deprecated. instead use the constructor Date(long date)
Date(long date)
Constructs a Date object using the given milliseconds time value.
Public Methods
int getHours()
This method is deprecated. As of JDK version 1.1, replaced by Calendar.get(Calendar.HOUR_OF_DAY).
int getMinutes()
This method is deprecated. As of JDK version 1.1, replaced by Calendar.get(Calendar.MINUTE).
int getSeconds()
This method is deprecated. As of JDK version 1.1, replaced by Calendar.get(Calendar.SECOND).
void setHours(int i)
This method is deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.HOUR_OF_DAY, int hours).
void setMinutes(int i)
This method is deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.MINUTE, int minutes).
void setSeconds(int i)
This method is deprecated. As of JDK version 1.1, replaced by Calendar.set(Calendar.SECOND, int seconds).
void setTime(long date)
Sets an existing Date object using the given milliseconds time value.
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 Date value.
[Expand]
Inherited Methods
From class java.util.Date
From class java.lang.Object
From interface java.lang.Comparable

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.
As of JDK version 1.1, replaced by Calendar.get(Calendar.HOUR_OF_DAY).

This method is deprecated and should not be used because SQL Date values do not have a time component.@deprecated

Returns
  • the hour represented by this date.
Throws
IllegalArgumentException if this method is invoked
See Also

public int getMinutes ()

This method is deprecated.
As of JDK version 1.1, replaced by Calendar.get(Calendar.MINUTE).

This method is deprecated and should not be used because SQL Date values do not have a time component.@deprecated

Returns
  • the number of minutes past the hour represented by this date.
Throws
IllegalArgumentException if this method is invoked
See Also

public int getSeconds ()

This method is deprecated.
As of JDK version 1.1, replaced by Calendar.get(Calendar.SECOND).

This method is deprecated and should not be used because SQL Date values do not have a time component.@deprecated

Returns
  • the number of seconds past the minute represented by this date.
Throws
IllegalArgumentException if this method is invoked
See Also

public void setHours (int i)

This method is deprecated.
As of JDK version 1.1, replaced by Calendar.set(Calendar.HOUR_OF_DAY, int hours).

This method is deprecated and should not be used because SQL Date values do not have a time component.@deprecated

Parameters
i the hour value.
Throws
IllegalArgumentException if this method is invoked
See Also

public void setMinutes (int i)

This method is deprecated.
As of JDK version 1.1, replaced by Calendar.set(Calendar.MINUTE, int minutes).

This method is deprecated and should not be used because SQL Date values do not have a time component.@deprecated

Parameters
i the value of the minutes.
Throws
IllegalArgumentException if this method is invoked
See Also

public void setSeconds (int i)

This method is deprecated.
As of JDK version 1.1, replaced by Calendar.set(Calendar.SECOND, int seconds).

This method is deprecated and should not be used because SQL Date values do not have a time component.@deprecated

Parameters
i the seconds value.
Throws
IllegalArgumentException if this method is invoked
See Also

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 toString ()

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

Returns
  • a String in yyyy-mm-dd format

public static Date valueOf (String 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-mm-dd"
Returns
  • a java.sql.Date object representing the given date
Throws
IllegalArgumentException if the date given is not in the JDBC date escape format (yyyy-mm-dd)