Date

public class Date extends 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 Constructor Summary

Date(int year, int month, int day)
This constructor was deprecated. instead use the constructor Date(long date)
Date(long date)
Constructs a Date object using the given milliseconds time value.

Public Method Summary

int
getHours()
This method was deprecated. This method is deprecated and should not be used because SQL Date values do not have a time component.
int
getMinutes()
This method was deprecated. This method is deprecated and should not be used because SQL Date values do not have a time component.
int
getSeconds()
This method was 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 was 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 was 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 was 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 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.

Inherited Method Summary

Public Constructors

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

This constructor was 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 was 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 if this method is invoked
See Also

public int getMinutes ()

This method was 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 if this method is invoked
See Also

public int getSeconds ()

This method was 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 if this method is invoked
See Also

public void setHours (int i)

This method was 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 if this method is invoked
See Also

public void setMinutes (int i)

This method was 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 if this method is invoked
See Also

public void setSeconds (int i)

This method was 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 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-[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 if the date given is not in the JDBC date escape format (yyyy-[m]m-[d]d)