public class Date
extends Date
| java.lang.Object | ||
| java.util.Date | ||
| java.sql.Date | ||
围绕毫秒值的精简包装,它允许JDBC将其标识为SQL DATE值。 毫秒值表示从1970年1月1日00:00:00开始经过的毫秒数。
为了符合SQL DATE的定义,必须通过将实例关联的特定时区中的小时,分钟,秒和毫秒设置为零来将“ java.sql.Date实例包装的毫秒值“标准化”。
Public constructors |
|
|---|---|
Date(int year, int month, int day) 此构造函数在API级别1中已弃用。请改用构造函数 |
|
Date(long date) 使用给定的毫秒时间值构造一个 |
|
公共方法(Public methods) |
|
|---|---|
int |
getHours() 此方法已弃用。 此方法已弃用,不应使用,因为SQL日期值没有时间组件。 |
int |
getMinutes() 此方法已弃用。 此方法已弃用,不应使用,因为SQL日期值没有时间组件。 |
int |
getSeconds() 此方法已弃用。 此方法已弃用,不应使用,因为SQL日期值没有时间组件。 |
void |
setHours(int i) 此方法已弃用。 此方法已弃用,不应使用,因为SQL日期值没有时间组件。 |
void |
setMinutes(int i) 此方法已弃用。 此方法已弃用,不应使用,因为SQL日期值没有时间组件。 |
void |
setSeconds(int i) 此方法已弃用。 此方法已弃用,不应使用,因为SQL日期值没有时间组件。 |
void |
setTime(long date) 使用给定的毫秒时间值设置现有的 |
String |
toString() 以日期转义格式yyyy-mm-dd格式化日期。 |
static Date |
valueOf(String s) 将JDBC日期转义格式的字符串转换为 |
继承方法(Inherited methods) |
|
|---|---|
java.util.Date
|
|
java.lang.Object
|
|
java.lang.Comparable
|
|
Date (int year,
int month,
int day)
此构造函数在API级别1中已弃用。
改为使用构造函数Date(long date)
构造一个以给定年份,月份和日期初始化的 Date对象。
如果给定的参数超出范围,结果是不确定的。
| 参数(Parameters) | |
|---|---|
year |
int: the year minus 1900; must be 0 to 8099. (Note that 8099 is 9999 minus 1900.) |
month |
int: 0 to 11 |
day |
int: 1 to 31 |
Date (long date)
使用给定的毫秒时间值构造一个Date对象。 如果给定的毫秒值包含时间信息,则驱动程序会将时间组件设置为与零GMT相对应的默认时区(运行应用程序的Java虚拟机的时区)中的时间。
| 参数(Parameters) | |
|---|---|
date |
long: 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. |
int getHours ()
此方法已弃用。
此方法已弃用,不应使用,因为SQL日期值没有时间组件。
返回此Date对象表示的小时数 。 返回的值是一个数字( 0到23 ),表示包含或以本地时区中解释的此Date对象所表示的时间点开始的一天中的小时数。
| 返回(Returns) | |
|---|---|
int |
the hour represented by this date. |
| 抛出异常(Throws) | |
|---|---|
IllegalArgumentException |
if this method is invoked |
也可以看看:
int getMinutes ()
此方法已弃用。
此方法已弃用,不应使用,因为SQL日期值没有时间组件。
返回此日期所表示的小时数,如本地时区中所解释的那样。 返回值在0和59之间。
| 返回(Returns) | |
|---|---|
int |
the number of minutes past the hour represented by this date. |
| 抛出异常(Throws) | |
|---|---|
IllegalArgumentException |
if this method is invoked |
也可以看看:
int getSeconds ()
此方法已弃用。
此方法已弃用,不应使用,因为SQL日期值没有时间组件。
返回此日期前一分钟的秒数。 返回的值在0和61之间。 值60和61只能在考虑闰秒的那些Java虚拟机上进行。
| 返回(Returns) | |
|---|---|
int |
the number of seconds past the minute represented by this date. |
| 抛出异常(Throws) | |
|---|---|
IllegalArgumentException |
if this method is invoked |
也可以看看:
void setHours (int i)
此方法已弃用。
此方法已弃用,不应使用,因为SQL日期值没有时间组件。
将此Date对象的小时数设置为指定值。 修改此Date对象,以便它表示在一天中的指定小时内的时间点,其中年,月,日,分和秒与以前相同,如本地时区中所解释的。
| 参数(Parameters) | |
|---|---|
i |
int: the hour value. |
| 抛出异常(Throws) | |
|---|---|
IllegalArgumentException |
if this method is invoked |
也可以看看:
void setMinutes (int i)
此方法已弃用。
此方法已弃用,不应使用,因为SQL日期值没有时间组件。
将此Date对象的分钟数设置为指定值。 此Date对象被修改,以便它表示在指定的一小时内的时间点,其中年,月,日,小时和秒与以前相同,如本地时区中所解释的。
| 参数(Parameters) | |
|---|---|
i |
int: the value of the minutes. |
| 抛出异常(Throws) | |
|---|---|
IllegalArgumentException |
if this method is invoked |
也可以看看:
void setSeconds (int i)
此方法已弃用。
此方法已弃用,不应使用,因为SQL日期值没有时间组件。
将此Date的秒数设置为指定值。 此Date对象被修改,以便它表示在指定的一分钟内的时间点,年,月,日,小时和分钟与以前相同,如本地时区中所解释的。
| 参数(Parameters) | |
|---|---|
i |
int: the seconds value. |
| 抛出异常(Throws) | |
|---|---|
IllegalArgumentException |
if this method is invoked |
也可以看看:
void setTime (long date)
使用给定的毫秒时间值设置现有的Date对象。 如果给定的毫秒值包含时间信息,则驱动程序会将时间组件设置为与零GMT相对应的默认时区(运行应用程序的Java虚拟机的时区)中的时间。
| 参数(Parameters) | |
|---|---|
date |
long: 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. |
String toString ()
以日期转义格式yyyy-mm-dd格式化日期。
| 返回(Returns) | |
|---|---|
String |
a String in yyyy-mm-dd format |
Date valueOf (String s)
将JDBC日期转义格式的字符串转换为 Date值。
| 参数(Parameters) | |
|---|---|
s |
String: 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) | |
|---|---|
Date |
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) |