关于编程规范-日期时间中“获取当前毫秒数”部分的表述
- Dominant language
- Kotlin
- Stars
- 30.8k
- Forks
- 8k
- PR merge metrics
- No merged PRs in 30d
Description
## 规约原文
【强制】获取当前毫秒数:System.currentTimeMillis(); 而不是new Date().getTime()。
说明:如果想获取更加精确的纳秒级时间值,使用System.nanoTime的方式。在JDK8中,针对统计时间等场景,推荐使用Instant类
## 问题描述
System.currentTimeMillis返回的时间是“墙上时钟”的时间,表示当前的时间值,这个值可能会因为操作系统或者ntp的时间调整后退;而System.nanoTime是“单调钟”,和当前时间没有关系,时间值不会后退,用于测量duration。这一点不同个人认为应该描述清楚,原文的表述容易造成“System.nanoTime能够比System.currentTimeMillis()更精确的获得当前时间”这样的误解
## 修改建议
参考问题描述部分
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the guideline text for getting the current millisecond value and read the surrounding explanation. Compare System.currentTimeMillis(), System.nanoTime(), and Instant so the revision clearly distinguishes wall-clock time from monotonic duration measurement and does not imply that nanoTime provides a more precise current time.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100