java.sql
Class Date

java.lang.Object sample code for java.lang.Object definition code for java.lang.Object 
  extended by java.util.Date sample code for java.util.Date definition code for java.util.Date 
      extended by java.sql.Date
All Implemented Interfaces:
Serializable sample code for java.io.Serializable definition code for java.io.Serializable , Cloneable sample code for java.lang.Cloneable definition code for java.lang.Cloneable , Comparable sample code for java.lang.Comparable definition code for java.lang.Comparable <Date sample code for java.util.Date definition code for java.util.Date >

public class Date
extends Date sample code for java.util.Date definition code for java.util.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.

See Also:
Serialized Form

Constructor Summary
Date sample code for java.sql.Date.Date(int, int, int) definition code for java.sql.Date.Date(int, int, int) (int year, int month, int day)
          Deprecated. instead use the constructor Date(long date)
Date sample code for java.sql.Date.Date(long) definition code for java.sql.Date.Date(long) (long date)
          Constructs a Date object using the given milliseconds time value.
 
Method Summary
 int getHours sample code for java.sql.Date.getHours() definition code for java.sql.Date.getHours() ()
          Deprecated.  
 int getMinutes sample code for java.sql.Date.getMinutes() definition code for java.sql.Date.getMinutes() ()
          Deprecated.  
 int getSeconds sample code for java.sql.Date.getSeconds() definition code for java.sql.Date.getSeconds() ()
          Deprecated.  
 void setHours sample code for java.sql.Date.setHours(int) definition code for java.sql.Date.setHours(int) (int i)
          Deprecated.  
 void setMinutes sample code for java.sql.Date.setMinutes(int) definition code for java.sql.Date.setMinutes(int) (int i)
          Deprecated.  
 void setSeconds sample code for java.sql.Date.setSeconds(int) definition code for java.sql.Date.setSeconds(int) (int i)
          Deprecated.  
 void setTime sample code for java.sql.Date.setTime(long) definition code for java.sql.Date.setTime(long) (long date)
          Sets an existing Date object using the given milliseconds time value.
 String sample code for java.lang.String definition code for java.lang.String toString sample code for java.sql.Date.toString() definition code for java.sql.Date.toString() ()
          Formats a date in the date escape format yyyy-mm-dd.
static Date sample code for java.sql.Date definition code for java.sql.Date valueOf sample code for java.sql.Date.valueOf(java.lang.String) definition code for java.sql.Date.valueOf(java.lang.String) (String sample code for java.lang.String definition code for java.lang.String  s)
          Converts a string in JDBC date escape format to a Date value.
 
Methods inherited from class java.util.Date sample code for java.util.Date definition code for java.util.Date
after sample code for java.util.Date.after(java.util.Date) definition code for java.util.Date.after(java.util.Date) , before sample code for java.util.Date.before(java.util.Date) definition code for java.util.Date.before(java.util.Date) , clone sample code for java.util.Date.clone() definition code for java.util.Date.clone() , compareTo sample code for java.util.Date.compareTo(java.util.Date) definition code for java.util.Date.compareTo(java.util.Date) , equals sample code for java.util.Date.equals(java.lang.Object) definition code for java.util.Date.equals(java.lang.Object) , getDate sample code for java.util.Date.getDate() definition code for java.util.Date.getDate() , getDay sample code for java.util.Date.getDay() definition code for java.util.Date.getDay() , getMonth sample code for java.util.Date.getMonth() definition code for java.util.Date.getMonth() , getTime sample code for java.util.Date.getTime() definition code for java.util.Date.getTime() , getTimezoneOffset sample code for java.util.Date.getTimezoneOffset() definition code for java.util.Date.getTimezoneOffset() , getYear sample code for java.util.Date.getYear() definition code for java.util.Date.getYear() , hashCode sample code for java.util.Date.hashCode() definition code for java.util.Date.hashCode() , parse sample code for java.util.Date.parse(java.lang.String) definition code for java.util.Date.parse(java.lang.String) , setDate sample code for java.util.Date.setDate(int) definition code for java.util.Date.setDate(int) , setMonth sample code for java.util.Date.setMonth(int) definition code for java.util.Date.setMonth(int) , setYear sample code for java.util.Date.setYear(int) definition code for java.util.Date.setYear(int) , toGMTString sample code for java.util.Date.toGMTString() definition code for java.util.Date.toGMTString() , toLocaleString sample code for java.util.Date.toLocaleString() definition code for java.util.Date.toLocaleString() , UTC sample code for java.util.Date.UTC(int, int, int, int, int, int) definition code for java.util.Date.UTC(int, int, int, int, int, int)
 
Methods inherited from class java.lang.Object sample code for java.lang.Object definition code for java.lang.Object
finalize sample code for java.lang.Object.finalize() definition code for java.lang.Object.finalize() , getClass sample code for java.lang.Object.getClass() definition code for java.lang.Object.getClass() , notify sample code for java.lang.Object.notify() definition code for java.lang.Object.notify() , notifyAll sample code for java.lang.Object.notifyAll() definition code for java.lang.Object.notifyAll() , wait sample code for java.lang.Object.wait() definition code for java.lang.Object.wait() , wait sample code for java.lang.Object.wait(long) definition code for java.lang.Object.wait(long) , wait sample code for java.lang.Object.wait(long, int) definition code for java.lang.Object.wait(long, int)
 

Constructor Detail

Date sample code for java.sql.Date(int, int, int) definition code for java.sql.Date(int, int, int)

@Deprecated
public Date(int year,
                       int month,
                       int day)
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

Date sample code for java.sql.Date(long) definition code for java.sql.Date(long)

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.
Method Detail

setTime sample code for java.sql.Date.setTime(long) definition code for java.sql.Date.setTime(long)

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.

Overrides:
setTime sample code for java.util.Date.setTime(long) definition code for java.util.Date.setTime(long) in class Date sample code for java.util.Date definition code for java.util.Date
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.

valueOf sample code for java.sql.Date.valueOf(java.lang.String) definition code for java.sql.Date.valueOf(java.lang.String)

public static Date sample code for java.sql.Date definition code for java.sql.Date  valueOf(String sample code for java.lang.String definition code for java.lang.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 sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if the date given is not in the JDBC date escape format (yyyy-mm-dd)

toString sample code for java.sql.Date.toString() definition code for java.sql.Date.toString()

public String sample code for java.lang.String definition code for java.lang.String  toString()
Formats a date in the date escape format yyyy-mm-dd.

NOTE: To specify a date format for the class SimpleDateFormat, use "yyyy.MM.dd" rather than "yyyy-mm-dd". In the context of SimpleDateFormat, "mm" indicates minutes rather than the month. For example:


  Format Pattern                         Result
  --------------                         -------
        "yyyy.MM.dd G 'at' hh:mm:ss z"    ->>  1996.07.10 AD at 15:08:56 PDT
 

Overrides:
toString sample code for java.util.Date.toString() definition code for java.util.Date.toString() in class Date sample code for java.util.Date definition code for java.util.Date
Returns:
a String in yyyy-mm-dd format
See Also:
Date.toLocaleString() sample code for java.util.Date.toLocaleString() definition code for java.util.Date.toLocaleString() , Date.toGMTString() sample code for java.util.Date.toGMTString() definition code for java.util.Date.toGMTString()

getHours sample code for java.sql.Date.getHours() definition code for java.sql.Date.getHours()

@Deprecated
public int getHours()
Deprecated. 

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

Overrides:
getHours sample code for java.util.Date.getHours() definition code for java.util.Date.getHours() in class Date sample code for java.util.Date definition code for java.util.Date
Returns:
the hour represented by this date.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if this method is invoked
See Also:
setHours(int) sample code for java.sql.Date.setHours(int) definition code for java.sql.Date.setHours(int)

getMinutes sample code for java.sql.Date.getMinutes() definition code for java.sql.Date.getMinutes()

@Deprecated
public int getMinutes()
Deprecated. 

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

Overrides:
getMinutes sample code for java.util.Date.getMinutes() definition code for java.util.Date.getMinutes() in class Date sample code for java.util.Date definition code for java.util.Date
Returns:
the number of minutes past the hour represented by this date.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if this method is invoked
See Also:
setMinutes(int) sample code for java.sql.Date.setMinutes(int) definition code for java.sql.Date.setMinutes(int)

getSeconds sample code for java.sql.Date.getSeconds() definition code for java.sql.Date.getSeconds()

@Deprecated
public int getSeconds()
Deprecated. 

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

Overrides:
getSeconds sample code for java.util.Date.getSeconds() definition code for java.util.Date.getSeconds() in class Date sample code for java.util.Date definition code for java.util.Date
Returns:
the number of seconds past the minute represented by this date.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if this method is invoked
See Also:
setSeconds(int) sample code for java.sql.Date.setSeconds(int) definition code for java.sql.Date.setSeconds(int)

setHours sample code for java.sql.Date.setHours(int) definition code for java.sql.Date.setHours(int)

@Deprecated
public void setHours(int i)
Deprecated. 

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

Overrides:
setHours sample code for java.util.Date.setHours(int) definition code for java.util.Date.setHours(int) in class Date sample code for java.util.Date definition code for java.util.Date
Parameters:
i - the hour value.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if this method is invoked
See Also:
getHours() sample code for java.sql.Date.getHours() definition code for java.sql.Date.getHours()

setMinutes sample code for java.sql.Date.setMinutes(int) definition code for java.sql.Date.setMinutes(int)

@Deprecated
public void setMinutes(int i)
Deprecated. 

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

Overrides:
setMinutes sample code for java.util.Date.setMinutes(int) definition code for java.util.Date.setMinutes(int) in class Date sample code for java.util.Date definition code for java.util.Date
Parameters:
i - the value of the minutes.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if this method is invoked
See Also:
getMinutes() sample code for java.sql.Date.getMinutes() definition code for java.sql.Date.getMinutes()

setSeconds sample code for java.sql.Date.setSeconds(int) definition code for java.sql.Date.setSeconds(int)

@Deprecated
public void setSeconds(int i)
Deprecated. 

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

Overrides:
setSeconds sample code for java.util.Date.setSeconds(int) definition code for java.util.Date.setSeconds(int) in class Date sample code for java.util.Date definition code for java.util.Date
Parameters:
i - the seconds value.
Throws:
IllegalArgumentException sample code for java.lang.IllegalArgumentException definition code for java.lang.IllegalArgumentException - if this method is invoked
See Also:
getSeconds() sample code for java.sql.Date.getSeconds() definition code for java.sql.Date.getSeconds()