jvm 2023-07-15

I'm having issue with java version and jackson

I'm having behavior of metosin/jsonista 0.3.7 work differently on java 1.8 and java 11

Almost certainly time/instant is not returning a joda time object, but a java Instant, so the first thing to do would be to use the Jackson module for the new java date time stuff

okay I updated the code inline above

to print (println (type instant))

in both cases (i.e., java 8 and 11) it is printing java.time.Instant

below is the java code

(ns com.example.jsonista-issue
  (:refer-clojure :exclude [read])
  (:require
   [jsonista.core :as json]
   [java-time.api :as time])
  (:import
   (com.fasterxml.jackson.databind ObjectMapper)
   (com.fasterxml.jackson.datatype.joda JodaModule)))

(def ^ObjectMapper base-object-mapper
  (json/object-mapper {:decode-key-fn true
                       :modules       [(JodaModule.)]
                       :date-format   "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"}))

(defn generate-string [obj]
  (json/write-value-as-string obj base-object-mapper))

(defn -main [& args]
  (let [instant (time/instant)].   (println (type instant))
    (println (System/getProperty "java.version"))
    (println (System/getProperty "java.vendor"))
    (println (generate-string instant))))

in 1.8 it gives below output

1.8.0_352
Azul Systems, Inc.
"2023-07-15T06:06:22.595Z"

and java 11 it gives below output

11.0.17
Azul Systems, Inc.
"2023-07-15T06:08:48.553587Z"

if you see in java 11 the precision is higher

Any idea how to fix this?