当前位置: 技术问答>java相关
为什么不能这样构造:Timestamp t = new Timestamp(2000,1,1,15,45,29,987245732);????
来源: 互联网 发布时间:2015-02-24
本文导语: 出现错误: --------------------Configuration: j2sdk -------------------- Note: E:jspnetj2sdkbinDatetest.java uses or overrides a deprecated API. Note: Recompile with -deprecation for details. 这个错误是什么意思,我改成Timestamp t = new Timestamp(987245732);就...
出现错误:
--------------------Configuration: j2sdk --------------------
Note: E:jspnetj2sdkbinDatetest.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
这个错误是什么意思,我改成Timestamp t = new Timestamp(987245732);就没有问题了,程序如下:
import java.sql.*;
public class Datetest {
public static void main(String[] args) {
Timestamp t = new Timestamp(2000,1,1,15,45,29,987245732);
java.util.Date d;
d = new java.util.Date(t.getTime() + (t.getNanos() / 2000000));
System.out.println(d);
}
}
|
Timestamp
public Timestamp(int year,
int month,
int date,
int hour,
int minute,
int second,
int nano)
Deprecated. instead use the constructor Timestamp(long millis)
Constructs a Timestamp object initialized with the given values.
Parameters:
year - the year minus 1900
month - 0 to 11
date - 1 to 31
hour - 0 to 23
minute - 0 to 59
second - 0 to 59
nano - 0 to 999,999,999
Throws:
IllegalArgumentException - if the nano argument is out of bounds
--------------------------------------------------------------------------------
Timestamp
public Timestamp(long time)
Constructs a Timestamp object using a milliseconds time value. The integral seconds are stored in the underlying date value; the fractional seconds are stored in the nanos field of the Timestamp object.
Parameters:
time - milliseconds since January 1, 1970, 00:00:00 GMT. A negative number is the number of milliseconds before January 1, 1970, 00:00:00 GMT.
See Also:
for more information
public Timestamp(int year,
int month,
int date,
int hour,
int minute,
int second,
int nano)
Deprecated. instead use the constructor Timestamp(long millis)
Constructs a Timestamp object initialized with the given values.
Parameters:
year - the year minus 1900
month - 0 to 11
date - 1 to 31
hour - 0 to 23
minute - 0 to 59
second - 0 to 59
nano - 0 to 999,999,999
Throws:
IllegalArgumentException - if the nano argument is out of bounds
--------------------------------------------------------------------------------
Timestamp
public Timestamp(long time)
Constructs a Timestamp object using a milliseconds time value. The integral seconds are stored in the underlying date value; the fractional seconds are stored in the nanos field of the Timestamp object.
Parameters:
time - milliseconds since January 1, 1970, 00:00:00 GMT. A negative number is the number of milliseconds before January 1, 1970, 00:00:00 GMT.
See Also:
for more information