Support printing and reading of Java 8 java.time.Instant

Description

In Clojure 1.9 alpha, limited support for Java 8 java.time.Instant was added, namely by (conditionally) extending the Inst protocol to that type.

It would be useful to enhance support for java.time.Instant further by

  • installing a print-method and print-dup for java.time.Instant

  • providing a read-instant function for reading java.time.Instant

This functionality is already provided in Clojure 1.8 today for the types java.util.Date, java.util.Calendar, and java.sql.Timestamp; extending it to java.time.Instant would be very helpful in environments using Java 8.

Environment

Java 8

Activity

Show:
Ghadi Shayban
June 27, 2018, 5:11 AM

If we make Instants print as #inst like java.util.Date, it could change roundtripping (a read #inst is by default a j.u.Date)

This would be nice when Java 8 is soon baseline for Clojure.

Will Cohen
July 9, 2018, 10:38 PM

CLJ-2224-p1.patch adds a print-method, print-dup, and read-instant-instant for java.time.Instant.

Enzzo Cavallo
May 5, 2020, 10:22 PM

Clojure 1.10+ only support Java 8+

https://github.com/clojure/clojure/blob/master/changes.md#11-java
Now “all supported java versions” have java.time.Instant

Will Cohen
May 6, 2020, 6:04 PM

p1.patch was out of date, CLJ-2224-p2.patch brings it up to date with current master.

Assignee

Unassigned

Reporter

David Bürgin

Labels

Approval

Triaged

Patch

None

Affects versions

Priority

Minor