JAVA获取当前系统时间System.currentTimeMillis()
2014-10-30 15:50
288 查看
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; }
相关文章推荐
- JAVA获取当前系统时间System.currentTimeMillis()
- Java获取当前系统时间System.currentTimeMillis()
- JAVA获取当前系统时间System.currentTimeMillis()
- JAVA获取当前系统时间System.currentTimeMillis()
- JAVA获取当前系统时间System.currentTimeMillis()
- JAVA获取当前系统时间System.currentTimeMillis()
- JAVA获取当前系统时间System.currentTimeMillis()
- JAVA获取当前系统时间System.currentTimeMillis()
- java使用new Date()和System.currentTimeMillis()获取当前时间戳(转载)
- Java中使用new Date()和System.currentTimeMillis()获取当前时间戳的区别(转)(Java进阶-性能提升)
- Java进阶(十六)使用new Date()和System.currentTimeMillis()获取当前时间戳
- java使用new Date()和System.currentTimeMillis()获取当前时间戳
- java中调用System.currentTimeMillis()获取当前时间来求出时间差及程序执行的时间
- java使用new Date()和System.currentTimeMillis()获取当前时间戳
- 大一新生第一次写java程序,用System.currentTimeMillis() 获取当前时间
- Java进阶(十六)使用new Date()和System.currentTimeMillis()获取当前时间戳
- C#:获取当前时间的总毫秒值(类似于Java中:System.currentTimeMillis() )
- java使用new Date()和System.currentTimeMillis()获取当前时间戳
- Java进阶(十六)使用new Date()和System.currentTimeMillis()获取当前时间戳
- java使用new Date()和System.currentTimeMillis()获取当前时间戳