(一)
java.util.Date
-----------
date.getTime()返回的是什么?
问题:
-------------
Date date = new Date();
System.out.println(date.getTime());
输出结果是1210745780625
编译时间当时时间大概是2008年5.14好14.16分
谁能给我解释下这数字分别是什么意思?
答案:
-------------
你想得到时间格式为2008-05-14这种吧?
date.getTime()所返回的是一个long型的毫秒数
获取特定格式的时间需要格式化的。
例子:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
sdf.format(new Date());
得到的日期格式为:2008-05-14
参考:http://lixh1986.iteye.com/blog/1757619
(二)
通常认为Date.getTime()可以得到得到1970年01月1日0点零分以来的毫秒数,
经过实践证明是错误的实际上通过Date.getTime()的到的是1970年01月01日8点中以来的毫秒数
参考:http://blog.youkuaiyun.com/linkyou/article/details/3983556
其它参考:
(三)
java使用new Date()和System.currentTimeMillis()获取当前时间戳,其中,new Date().getTime获取毫秒数,效率不如System.currentTimeMillis()来获取毫秒数。
public Date() { this(System.currentTimeMillis()); }
参考:http://www.cnblogs.com/wuchen/archive/2012/06/30/2570746.html