Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8068730 Increase the precision of the implementation of java.time.Clock.systemUTC()
  3. JDK-8164428

Release Note: The implementation of the clock returned by system factory methods in java.time.Clock has increased the resolution

XMLWordPrintable

    • Verified

      The Java SE 8 specification for `java.time.Clock` states that *''The system factory methods provide clocks based on the best available system clock. This may use `System.currentTimeMillis()`, or a higher resolution clock if one is available.''* In JDK 8 the implementation of the clock returned was based on `System.currentTimeMillis()`, and thus has only a millisecond resolution. In JDK 9, the implementation is based on the underlying native clock that `System.currentTimeMillis()` is using, providing the maximum resolution available from that clock. On most systems this can be microseconds, or sometimes even tenth of microseconds.

      An application making the assumption that the clock returned by these system factory methods will always have milliseconds precision and actively depends on it, may therefore need to be updated in order to take into account the possibility of a greater resolution, as was stated in the API documentation. It is also worth noting that a new `Clock.tickMillis(zoneId)` method has been added to allow time to be obtained at only millisecond precision - see: [http://download.java.net/java/jdk9/docs/api/java/time/Clock.html#tickMillis-java.time.ZoneId-](http://download.java.net/java/jdk9/docs/api/java/time/Clock.html#tickMillis-java.time.ZoneId-).

            dfuchs Daniel Fuchs
            rcalnan Roger Calnan
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: