I'm a little confused.
I have a Spring Boot application (Spring Boot version 4.0.1).
There's a simple DDL:

create table foo ( id serial not null primary key, dt timestamptz not null );

And an entity:

@Getter @Setter @Entity public class Foo { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; private OffsetDateTime dt; public Foo() {} public Foo(OffsetDateTime dt) { this.dt = dt; } }

I've got an API:

@GetMapping public List<Foo> getAll() { return repository.findAll(); }

After calling the API I expect a dt field returned in a timezone specified by JVM (or from -Duser.timezone). But it's returned always in UTC.
I tried to use ?serverTimezone in a JDBC connection url, set -Duser.timezone, use explicitly set timezone in Postgres (using docker and environment variables TZ and PGTZ). But nothing.

Probably I misundestand how it should work. I've expected that returned from DB date times would be in a timezone specified by JDBC driver's client (JVM in this case).

Artyom's user avatar

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.