date.gettime()返回的是什么?
来源:互联网 发布:淘宝新店引流软件 编辑:程序博客网 时间:2024/05/17 03:40
(一)
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.csdn.net/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
0 0
- date.gettime()返回的是什么?
- date.gettime()返回的是什么?
- date.gettime()返回的是什么?
- date.gettime()返回的是什么,以及格式化日期模板
- ate.gettime()返回的是什么?
- Date类的getTime()方法
- 关于new Date().getTime()的简写方式.
- date.gettime()与时间的获取
- JavaScript:Date对象的getTime()方法
- java中Date的getTime()函数
- javascript的date()和getTime()区别
- 关于new Date().getTime()的简写方式.
- Date.getTime() 方法
- date.getTime() 转换成 date
- new Date(date).getTime()兼容性
- js的Date.parse()方法和getTime()的陷阱
- Date().getTime()线程堵塞问题
- JS之new Date().getTime()
- 喷水装置
- linux c/c++ GDB教程详解
- OC-遍历集合类
- spring security3.x学习(24)_拒绝访问异常处理(AccessDeniedException)
- Spark GraphX 入门实例完整scala代码
- date.gettime()返回的是什么?
- 第十七周项目四—生日差几天
- 七款代码味道识别工具【简介】
- Sequence
- Tar 记录
- C++编译遇到问题汇总
- 对等复制
- spring security3.x学习(25)_bean配置跑spring security(mysql数据库)
- int main(int argc , char **argv )