java当中的Date型数据
请问/*** 创建Date类型的变量 this is date :Sat Dec 06 00:26:54 CST 2008
* 程序运行过程中直接将当前的时间打印出来
*/
Date date = new Date();
System.out.println("this is date :" + date);
其中的Date类型的变量的代码是怎么样子的呀 --------------------编程问答-------------------- 直接在你安装JDK的目录下,找到src.zip就能看到Java代码了。
构造函数是:
/**
* Allocates a <code>Date</code> object and initializes it so that
* it represents the time at which it was allocated, measured to the
* nearest millisecond.
*
* @see java.lang.System#currentTimeMillis()
*/
public Date() {
this(System.currentTimeMillis());
}
/**
* Allocates a <code>Date</code> object and initializes it to
* represent the specified number of milliseconds since the
* standard base time known as "the epoch", namely January 1,
* 1970, 00:00:00 GMT.
*
* @param date the milliseconds since January 1, 1970, 00:00:00 GMT.
* @see java.lang.System#currentTimeMillis()
*/
public Date(long date) {
fastTime = date;
}
--------------------编程问答--------------------
楼主的这段代码不就输出来了日期时间,,如果要想输出上面的格式,只需要把date用DataFormat类中的方法格式化一下就好了,
补充:Java , Java相关