我需要找出两个时间值之间的差异,其中一个是使用系统获取的。currentTimeMillis(),即它是the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC,另一个是使用System.nanoTime()获取的,这意味着它是current value of the running Java Virtual Machine's high-resolution time source, in nanoseconds。
我该怎么做呢?
发布于 2013-12-10 23:01:08
你不能比较它们;它们是苹果和橙子,不是以相同的尺度或相对于相同的时间点测量的。特别是,虽然currentTimeMillis()是从1/1/1970 00:00:00Z开始的毫秒,但nanoTime()是从...开始测量的。嗯,可能是您的机器的启动时间,或者JVM的启动时间,或者任何东西的启动时间。
如果同时调用这两个方法并注意到相关性,则可以在以后执行类似的关联,但这是唯一的方法,并且不能保证是准确的。
https://stackoverflow.com/questions/20497668
复制相似问题