Fix timestamp timezone issues by forcing UTC and storing with the timezone

PostgreSQL is pretty insistent on returning results in the timezone
of the client, in this case the JVM.  But we want everything in the
JVM to be in UTC, because that's what the native Java date types work
on and operate with.

By forcing values to be set in UTC, and normalized back to UTC by
applying any embedded timezone offset before making the Timestamp
available to the application we can hide this behavior.

Columns in PostgreSQL are marked "WITH TIME ZONE" so Postgres is
able to store everything in UTC, and know for a fact that they
are all UTC values.

Signed-off-by: Shawn O. Pearce <sop@google.com>
2 files changed