Date - JRE Emulation | JRE Emulation
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. 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 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 Methods
[Expand]
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.
This method is deprecated and should not be used because SQL Date values do not have a time component.

Returns the gregorian calendar hour of the day for this Date object.

Returns
  • the hour of the day.
Throws
IllegalArgumentException if this method is invoked
See Also

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 gregorian calendar minute of the hour for this Date object.

Returns
  • the minutes.
Throws
IllegalArgumentException if this method is invoked
See Also

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 gregorian calendar second of the minute for this Date object.

Returns
  • the seconds.
Throws
IllegalArgumentException if this method is invoked
See Also

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 gregorian calendar hour of the day for this Date object.

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

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 gregorian calendar minute of the hour for this Date object.

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

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 gregorian calendar second of the minute for this Date object.

Parameters
i the seconds.
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)