# Java Time (JSR-310) enhancements in Java SE 9

DevFeed: [Java Time (JSR-310) enhancements in Java SE 9](<https://devfeed.tech/articles/java-time-jsr-310-enhancements-in-java-se-9-21993.md>)

Original publisher: [Read original article](<http://blog.joda.org/2017/02/java-time-jsr-310-enhancements-java-9.html>)

Author: Stephen Colebourne (noreply@blogger.com)

Published: 2017-02-07T14:47:00Z

Content type: article

Language: en

Sources: [Stephen Colebourne](<https://devfeed.tech/sources/stephen-colebourne.md>)

Topics: [jsr310](<https://devfeed.tech/topics/jsr310.md>)

Tags: [added](<https://devfeed.tech/tags/added.md>), [api](<https://devfeed.tech/tags/api.md>), [clock](<https://devfeed.tech/tags/clock.md>), [conversion](<https://devfeed.tech/tags/conversion.md>), [days](<https://devfeed.tech/tags/days.md>), [enhancement](<https://devfeed.tech/tags/enhancement.md>), [instant](<https://devfeed.tech/tags/instant.md>), [java](<https://devfeed.tech/tags/java.md>), [java-se](<https://devfeed.tech/tags/java-se.md>), [java9](<https://devfeed.tech/tags/java9.md>), [jdk](<https://devfeed.tech/tags/jdk.md>), [jsr310](<https://devfeed.tech/tags/jsr310.md>), [localdate](<https://devfeed.tech/tags/localdate.md>), [minutes](<https://devfeed.tech/tags/minutes.md>), [optimize](<https://devfeed.tech/tags/optimize.md>), [optimized](<https://devfeed.tech/tags/optimized.md>), [performance](<https://devfeed.tech/tags/performance.md>), [precision](<https://devfeed.tech/tags/precision.md>), [returning](<https://devfeed.tech/tags/returning.md>), [stream](<https://devfeed.tech/tags/stream.md>), [time](<https://devfeed.tech/tags/time.md>), [use-cases](<https://devfeed.tech/tags/use-cases.md>)

## AI overview

Java SE 9's java.time updates add date streaming, duration operations, and more direct conversions to epoch seconds. Clock.systemUTC() gains precision according to the operating system clock; Clock.tickMillis(ZoneId) preserves Java SE 8-style millisecond ticks when needed. DateTimeFormatter gains modified Julian day and generic time-zone patterns, supports more offset forms, and improves adjacent-value parsing. The excerpt also describes performance optimizations for clocks, zone lookups, and LocalDate.plusDays. It identifies these as selected enhancements among 117 targeted issues, many of which were Javadoc fixes.

## Source excerpt

The java.time.* API (JSR-310) was added to Java SE 8, but what has been going on since then? Java Time in Java SE 9 There are currently 117 java time issues targetted into Java SE 9. Most of these are not especially interesting, with a lot of mistakes in the Javadoc that needed fixing. What follows are some of the interesting ones: Main enhancements: JDK-8146218 - Add LocalDate.datesUntil method producing Stream. Adds two new methods - LocalDate.datesUntil(LocalDate) and LocalDate.datesUntil(LocalDate,Period) - returning a stream of dates. JDK-8068730 - Increase precision of Clock.systemUTC(). The clock in Java - System.currentTimeMillis() - has ticked in milliseconds since Java was first released. With Java SE 9, users of Clock will see higher precision, depending on the available clock of the operating system. JDK-8071919 - Clock.tickMillis(ZoneId zone) method. With the system clock now returning higher precision, a new method was added - Clock.tickMillis(ZoneId) - that chops off the extra precision to restrore the millisecond ticking behaviour of Java SE 8. JDK-8030864 - Add efficient getDateTimeMillis method to java.time. This adds two methods named epochSecond to Chronology that have no object creation to convert date-time fields to an epoch-second. JDK-8142936 - Duration methods for days, hours, minutes, seconds, etc. The Java SE 8 API of Duration turned out to be incomplete for certain use cases. This change adds a slew of new methods that allow parts of the duration to be reliably returned. JDK-8148849 - Truncating Duration. Adds a method Duration.truncatedTo(TemporalUnit) to allow truncation, similar to the existing method on Instant. JDK-8032510 - Add Duration.dividedBy(Duration). A new method to allow a duration to be divided by another duration. JDK-8133079 - LocalDate and LocalTime ofInstant() factory methods. Add new factory methods in LocalDate and LocalTime to simplify conversion from Instant. JDK-8143413 - Add toEpochSecond methods for efficient acc