【发布时间】:2019-12-23 18:30:08
【问题描述】:
我正在尝试将时间(以秒为单位)转换为带有时区的时间戳。
我试过了
(defn- seconds-to-milliseconds[time]
(* time 1000))
(:require [clj-time.coerce :as clj-time])
(clj-time/from-long (seconds-to-milliseconds 1564132000))
结果是:#clj-time/date-time"2019-07-26T09:06:40.000Z"
但是这个结果我不能存储在 Postgres 数据库中,因为我得到了
PSQLException: Can't infer the SQL type to use for an instance of org.joda.time.DateTime. Use setObject() with an explicit Types value to specify the type to use
所以我需要转换它
(clj-time/to-timestamp (clj-time/from-long (seconds-to-milliseconds 1564132000))))
结果是
#inst"2019-07-26T09:06:40.000000000-00:00"
我可以将它存储在 postgres 中,但它没有时区。
谁能帮我将时间(以秒为单位)转换为带时区的时间戳。
【问题讨论】:
标签: clojure