apache / apache/lucene

Use TimeUnit.TARGETUNIT.convert() to convert between time units [LUCENE-7014]

Open
#8,071 5 comments 0 reactions 0 assignees View on GitHub
affects-version:5.4.1 affects-version:6.0 legacy-jira-fix-version:6.0 legacy-jira-priority:Minor type:enhancement
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

Re-phrased from @sarowe's [comment](https://issues.apache.org/jira/browse/LUCENE-6823?focusedCommentId=14941283&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14941283) :

System.nanoTime(), which is guaranteed to be monotonic, is now used to recored elapsed times. In several places, conversion from nano seconds to some target unit (e.g. seconds, milli seconds) is performed using hard-coded conversion constants, which is prone to mistakes.

It would be nice to use `TimeUnit.TARGETUNIT.convert(sourceDuration, TimeUnit.SOURCEUNIT)` instead.

---
Migrated from [LUCENE-7014](https://issues.apache.org/jira/browse/LUCENE-7014) by Ahmet Arslan (@iorixxx), updated Mar 07 2018
Attachments: [LUCENE-7014.patch](https://apache.github.io/lucene-jira-archive/attachments/LUCENE-7014/LUCENE-7014.patch) (versions: 2)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.