Thread: timestamp with time zone wire format

timestamp with time zone wire format

From
Philippe Marschall
Date:
Hi

I'm a bit annoyed by the lack of java.time / JSR-310 support (mostly
ZonedDateTime and OffsetDateTime). Annoyed enough to look into what
would be required to implement it. The first thing I would need is a
documentation of the wire format of TIMESTAMP WITH TIME ZONE
(Oid.TIMESTAMPTZ I believe) so that I can write parse code. I first
though about putting it into TimestampUtils but for backwards
compatibility with older Java/JDBC versions a dedicated class would
probably be better.

This is not a promise that I'll work on it let alone deliver something.

Cheers
Philippe


Re: timestamp with time zone wire format

From
Vladimir Sitnikov
Date:
> I can write parse code

Parse code for timestampTZ is probably there. The missing part is
conversion from-to JSR-310.

> for backwards compatibility with older Java/JDBC versions a dedicated class would probably be better

Things will get much easier after
https://github.com/pgjdbc/pgjdbc/pull/435 is merged in.
It will enable pre-processor, so it would be possible to seamlessly
integrate java.time right into `statement.getObject` without failing
the build for older java versions.

Here's an example:

https://github.com/vlsi/pgjdbc/blob/2236505772e8d36640929b8a75fa3857f0bfbb94/core/src/main/java/org/postgresql/jdbc/PgResultSet.java#L3471-L3491

Vladimir


Re: timestamp with time zone wire format

From
Philippe Marschall
Date:
On 14.12.15 14:43, Vladimir Sitnikov wrote:
>> I can write parse code
>
> Parse code for timestampTZ is probably there. The missing part is
> conversion from-to JSR-310.

The only thing I could find is TimestampUtils#toTimestampBin [1] there
the time zone either comes from the caller or the system default, never
the database. Form reading the docs I get the impression the time zone
isn't stored so there's nothing to parse.

>> for backwards compatibility with older Java/JDBC versions a dedicated class would probably be better
>
> Things will get much easier after
> https://github.com/pgjdbc/pgjdbc/pull/435 is merged in.

Is there an ETA for this?

  [1]
https://github.com/pgjdbc/pgjdbc/blob/master/org/postgresql/jdbc2/TimestampUtils.java#L623

Cheers
Philippe



Re: timestamp with time zone wire format

From
Vladimir Sitnikov
Date:
> time zone either comes from the caller or the system default, never the database

As far as I can tell, DB does not send time zone when using binary
encoding (see [1]).

[1]
https://github.com/postgres/postgres/blob/d4355425831fe8f6a68095393e3628cb30d06b3f/src/backend/utils/adt/timestamp.c#L792-L807

>Is there an ETA for this?

Hopefully it will be in 2015.

Vladimir


Re: timestamp with time zone wire format

From
Philippe Marschall
Date:
On 15.12.15 09:16, Vladimir Sitnikov wrote:
>> time zone either comes from the caller or the system default, never the database
>
> As far as I can tell, DB does not send time zone when using binary
> encoding (see [1]).

And for non binary encoding it will probably use the system's TimeZone
parameter.

Cheers
Philippe