Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8285519

Change usages of TimeUnit.convert to TimeUnit.toXXX

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P5
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 20
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b03

      Description

      If target TimeUnit is known at compile time, we can use TimeUnit.toSomething method instead of TimeUnit.convert.
      E.g.

          TimeUnit.MILLISECONDS.convert(adjust, TimeUnit.NANOSECONDS);

      Could be replaced with

          TimeUnit.NANOSECONDS.toMillis(adjust);

      It's shorter and a bit faster.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              aturbanov Andrey Turbanov
              Reporter:
              aturbanov Andrey Turbanov
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: