System.currentTimeMillis()和new Date().getTime()比较

Posted mr_level

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了System.currentTimeMillis()和new Date().getTime()比较相关的知识,希望对你有一定的参考价值。

获取时间毫秒数时System.currentTimeMillis()方法比new Date().getTime()效率高, 因为new Date().getTime()方法调用的System.currentTimeMillis()

 

Date类的构造函数直接调用的System.currentTimeMillis()获取fastTime毫秒值:

 

getTime()方法在cdate为空(Date对象在进行无参构造创建对象时cdate默认为null)的情况下直接返回fastTime.

以上是关于System.currentTimeMillis()和new Date().getTime()比较的主要内容,如果未能解决你的问题,请参考以下文章

System.currentTimeMillis() 是不是返回 UTC 时间?

给定日期的 System.currentTimeMillis()? [复制]

System.nanoTime()和System.currentTimeMillis()性能问题

System.currentTimeMillis()

System.currentTimeMillis() uptimeMillis() elapsedRealtime() 区别

System.currentTimeMillis()和new Date().getTime()比较