DST and Timestamp

28 views
Skip to first unread message

Richard Rodseth

unread,
May 18, 2016, 8:10:02 PM5/18/16
to scala...@googlegroups.com
I'm dealing with a legacy postgres table with start/end values of type "timestamp without timezone". These values are intended to be interpreted as UTC.
My table mappings use type Timestamp.

I'm doing a streaming query and writing to a file as Longs. Most values are as expected, but
in March (start of DST)

2:45 - 3:00 (10:45 to 11:00 UTC) becomes 10:45-10:00

I see there is an outstanding issue for Java 8 support


and apparently JDBC also lets you specify a Calendar when fetching time stamps.
Then there's slick-pg.

Recommendations, please?

Richard Rodseth

unread,
May 19, 2016, 12:40:12 PM5/19/16
to scala...@googlegroups.com
I am able to get correct results if I run the program with -Duser.timezone=UTC
JDBC APIs let you supply a Calendar when getting time values from a ResultSet.

I thought perhaps I could make a composite action in Slick, and set the timezone on a per-connection basis, but it didn't seem to work, and furthermore the composite action doesn't have the "statements" method. 

    val intervalsAction = query.result

    println(s"*********** ${intervalsAction.statements}")

    val setTimeZoneAction = sqlu"SET TIME ZONE 'UTC';"

    val finalAction = setTimeZoneAction.andThen(intervalsAction)

    println(s"*********** ${finalAction.statements}") // Does not compile

Richard Rodseth

unread,
May 20, 2016, 8:01:23 PM5/20/16
to scala...@googlegroups.com
Can anyone please point me at an example of overriding MappedJdbcType rather than using MappedColumnType.base. I need access to the ResultSet so I can pass a Calendar to getTime.
Reply all
Reply to author
Forward
0 new messages