-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support Java8 dates oob with EDN & Transit too #92
Comments
I'd like to help with this, but it's unclear where it would best go. Is the right approach to extend a protocol with the JDK8 datetime classes? |
I think this is the general gist of it:
I guess it's not too hard to implement - the real question is what tagged value names are appropriate? |
I think that we should use the default tags where possible: in EDN, |
FYI This is what I did for Instant: (def transit-write-handlers
{java.time.Instant
(cognitect.transit/write-handler
"t"
(fn [^java.time.Instant inst]
(.format
(com.cognitect.transit.impl.AbstractParser/getDateTimeFormat)
(java.util.Date/from inst))))})
; => send `{:handlers transit-write-handlers}` to `writer` it is a hack because it relies on implementation details of transit-java but it guarantees that any existing client will be able to read it as a Date. |
In the interest of helping others who stumble on the workarounds described in this thread, here's a concrete implementation wired into I've used @holyjak 's hack because the default This blog post is old, but was handy for context since I'm unfamiliar with all these libraries: https://increasinglyfunctional.com/2014/09/02/custom-transit-writers-clojure-joda-time.html |
Muuntaja depends on Java8. Java8 has
java.time
package with the de facto new Classes for different date & time representations. Muuntaja should support serialization & deserialization of the classes for all default formats: JSON, EDN and Transit. Jsonista already has support, EDN and Transit should be verified & implemented.relevant discussion: https://clojureverse.org/t/migrating-from-clj-time-to-java-time/3251/6
The text was updated successfully, but these errors were encountered: