System.currentTimeMillis()产生一个当前的毫秒,这个毫秒其实就是自1970年1月1日0时起的毫秒数,Date()其实就是相当于Date(System.currentTimeMillis());因为Date类还有构造Date(long date),用来计算long秒与1970年1月1日之间的毫秒差。
得到了这个毫秒数,我们自己也可以算起现在的年月日周时,但是这不是我们去计算的,因为有Calendar。Calendar最终出的结果就是年月日周时时区。
System.currentTimeMillis() 获得的是自1970-1-01 00:00:00.000 到当前时刻的时间距离,类型为long
String.valueOf(System.currentTimeMillis()) 这个语句可转为以下的型式:
long ct = System.currentTimeMillis();
String t = String.valueOf(ct);
其实上面的String t就相当于 ct+"";
只是转为字符串格式

public String refFormatNowDate() {
  Date nowTime = new Date(System.currentTimeMillis());
  SimpleDateFormat sdFormatter = new SimpleDateFormat("yyyy-MM-dd");
  String retStrFormatNowDate = sdFormatter.format(nowTime);

return retStrFormatNowDate;

链接来源:http://blog.sina.com.cn/s/blog_7309444701016yv5.html

最新文章

  1. Spring 发送 Email
  2. 17.2---#字棋(CC150)
  3. Android 设计模式一:EIT造型
  4. (WPF) 再议binding:点击User Control时,User Control变换颜色或做其他的处理。
  5. Context上下文
  6. 实现 iframe 子页面调用父页面中的js方法
  7. DEEP LEARNING IS THE FUTURE: Q&A WITH NAVEEN RAO OF NERVANA SYSTEMS
  8. 推断类型var
  9. Atitit。团队建设--管理最佳实践--如何留住关键人才,防止人才外流 ??
  10. leetcode[94] Unique Binary Search Trees
  11. 【数据标识】iOS App下载渠道的统计需求
  12. Angular 学习笔记 ( CDK - Observers )
  13. Apache 443端口占用解决方法
  14. ProxyChains 的坑, 需要关闭 sip
  15. Zookeeper~Linux环境下的部署
  16. python各模块组合实例
  17. python常用模块之os模块
  18. sql-connectionStrings
  19. [剑指Offer]24-反转链表
  20. 使用开源Breeze工具部署Kubernetes 1.12.1高可用集群

热门文章

  1. Android启动篇 — init原理(二)
  2. Extjs6官方文档译文——应用架构简介(MVC,MVVM)
  3. Angularjs快速入门(二)
  4. git 利用分支概念实现一个仓库管理两个项目
  5. 运行出错之未能加载文件或程序集“Microsoft.ReportViewer.Common, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91”或它的某一个依赖项。系统找不到指定的文件。文件名:“Microsoft.ReportViewer.Common, Version=11.0.0.0,
  6. 蓝桥杯-无穷分数-java
  7. VMware安装CentOS 6.7系统
  8. angularjs ng-class
  9. OA办公系统,一个沉淀企业文化的容器
  10. OC 中 @synthesize 关键字介绍和使用