datomic

Ask questions on the official Q&A site at https://ask.datomic.com!
nando 2020-10-03T00:06:23.190Z

(t/instant? (.toInstant #inst "2020-09-26T23:08:27.619-00:00")) => true (t/instant? (t/instant #inst "2020-09-26T23:08:27.619-00:00")) => true

nando 2020-10-03T00:23:34.190200Z

This works: (t/format "<http://yyyy.MM|yyyy.MM>.dd" (t/zoned-date-time 2015 9 28)) => "2015.09.28" but I can't find a way to convert a datomic db.type/instant to a zoned-date-time.

nando 2020-10-03T00:36:37.190400Z

There must be a more straightforward way to format datomic datetime values.

seancorfield 2020-10-03T04:45:06.190600Z

@nando

user=&gt; (t/format "dd/MM/yyyy" (t/zoned-date-time #inst "2020-09-26T23:08:27.619-00:00" (t/zone-id "UTC")))
"26/09/2020"
user=&gt; 

seancorfield 2020-10-03T04:45:27.190800Z

(or whatever TZ you need there)

seancorfield 2020-10-03T04:51:42.191Z

Although if you're dealing with #inst which I believe are just regular java.util.Date objects, this should work (without clojure.java-time at all):

user=&gt; (let [f (java.text.SimpleDateFormat. "dd/MM/yyyy")]
         (.format f #inst "2020-09-26T23:08:27.619-00:00"))
"26/09/2020"
user=&gt; 

seancorfield 2020-10-03T04:53:11.191200Z

Yup, Datomic docs say it's just a java.util.Date:

:db.type/instant	instant in time	java.util.Date	#inst "2017-09-16T11:43:32.450-00:00"