在Java中,最快的获取系统时间的方法是什么? [英] In Java, what is the fastest way to get the system time?

查看:45
本文介绍了在Java中,最快的获取系统时间的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个经常使用系统时间的系统,因为 Delayed 接口.

I'm developing a system that often use the system time because the Delayed interface.

从系统获取时间的最快方法是什么?

What is fastet way to get the time from system?

目前,每次需要打发时间时,我都会使用 Calendar.getInstance().getTimeInMillis(),但是我不知道是否有更快的方法.

Currently I'm using Calendar.getInstance().getTimeInMillis() every time I need to get the time, but I don't know if there is a faster way.

推荐答案

.
使用它来获取实际的系统时间.

系统.nanoTime() .
返回的值表示自某个固定但任意的原始时间以来的纳秒"
使用它来衡量时间流逝/事件.

这篇关于在Java中,最快的获取系统时间的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆