I had a similar problem: correct timestamps are returned by JDBC queries 
with timezone offset. I think this is due to the fact that PostgreSQL 
automatically stores timestamps in 
UTC<http://www.postgresql.org/docs/9.3/static/datatype-datetime.html>(emphasis 
is mine):

For timestamp with time zone, the internally stored value is always in UTC 
(Universal Coordinated Time, traditionally known as Greenwich Mean Time, 
GMT). An input value that has an explicit time zone specified is converted 
to UTC using the appropriate offset for that time zone. *If no time zone is 
stated in the input string, then it is assumed to be in the time zone 
indicated by the system’s TimeZone parameter, and is converted to UTC using 
the offset for the timezone zone*.

I ended up using a workaround: formatting the timestamps using the timezone 
offset. However I'm sure there is a better way.

Il giorno lunedì 21 ottobre 2013 16:33:29 UTC+2, Vincent Liard ha scritto:
>
> Hello,
>
> I'm having a hard time figuring out a timestamp problem with clojure 
> 1.5.1, clojure/java.jdbc 0.3.0-alpha5 and clojure/postgresql 9.1-901.jdbc4 
> (with postgresql 9.1.9).
> With the same timestamp I get different results from PostgreSQL client and 
> from clojure. PSQL answers what I expect :
>
> psql> select timestamp '2013-10-21 12:00:00';
>       timestamp      
> ---------------------
>  2013-10-21 12:00:00
> (1 row)
>
> But clojure...
>
> clj> (clojure.java.jdbc/query db ["select timestamp '2013-10-21 
> 12:00:00'"])
> ({:timestamp #inst "2013-10-21T10:00:00.000000000-00:00"})
>
> I would think I should get the same results in both cases. Why is JDBC or 
> clojure.jdbc adding some timezone on the fly?
>
> It's also likely related to a daylight saving time issue since the 
> difference changes according to the date.
>
> > select timestamp '2013-02-21 12:00:00';
>       timestamp      
> ---------------------
>  2013-02-21 12:00:00
> (1 row)
>
> clj> (clojure.java.jdbc/query db ["select timestamp '2013-02-21 
> 12:00:00'"])
> ({:timestamp #inst "2013-02-21T11:00:00.000000000-00:00"})
>
> Is there a bug around or am I misunderstanding something ?
> Thanks for any hint,
>
> Vincent
>
>

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to