Reputation: 21
When running a query on a postgres database on a clojure REPL, the timestamps fields are presented in UTC and I need them to be in timezone America/Sao_Paulo (UTC-3)
So far I have tried the following on Intellij's REPL:
-Duser.timezone=America/Sao_Paulo
inside the file idea.vmoptions
(intellij's):jvm-opts ["-Duser.timezone=America/Sao_Paulo"]
to project.clj-Duser.timezone=America/Sao_Paulo
in Intellij's REPL configurationJAVA_OPTS="-Duser.timezone=America/Sao_Paulo:$JAVA_OPTS"
inside ~/.zshrc
and the following on Leiningen REPL:
:jvm-opts ["-Duser.timezone=America/Sao_Paulo"]
to project.cljJAVA_OPTS="-Duser.timezone=America/Sao_Paulo:$JAVA_OPTS"
inside ~/.zshrc
None worked so far!
Sample code
(ns experiments
(:require [next.jdbc :as jdbc]))
(def db
{:dbtype "postgres"
:dbname "<dbname>"
:host "<host>"
:port 5432
:user "<user>"
:password "<pass>"})
(def ds (jdbc/get-datasource db))
(jdbc/execute! ds ["select current_timestamp"])
Upvotes: 2
Views: 543
Reputation: 29958
You did not mention any Postgres options. Please study this page carefully for info and options.
If the above does not solve your problem, it may be easiest to use java.time to do the conversion. I also have some helper/convenience functions available here. Unit tests show them in action, and the source code provides examples of java.time
interop from clojure.
I would avoid the older Joda Time libraries as they are obsolete (replaced by java.time). I think that Java interop is the easiest & most straightforward way to access java.time
.
Upvotes: 1