Missing offset on OffsetDatetime on retrieval from DB

47 views Asked by At

Hello I am struggling with zone offset on OffsetDatetime fields I have in my app.

I simulated it in tests. I created a datetime which is displayed as 2023-12-25T09:53:55+01:00 when debugging. When I save it to db and then retrieve it my assert fails with the actual value being: 2023-12-25T08:53:55Z

Tests use hsql db, runtime uses postgres. When I look in the postgres I see offsets correctly f.e. 2021-11-14 19:34:43.168034 +00:00 (data type is timestamp with timezone) and when I test it over api, I also see Z being returned instead of an actual offset, I have annotation @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)over that given field, but I suppose the problem is somewhere between db and app.

I don't have any special config for an object mapper. Currently I'm using SpringBoot 3.2.1 but it seems to happen on the older version which is 2.7 or sth.

Update:

It looks like it's not just a problem with HSQL in tests it works the same in runtime with Postgre. What I found out is that when the data is mapped from DB to entity class, the offset is applied according to the local date time instead of being present separately in the OffsetDateTime attribute, I am not sure why tho yet.

0

There are 0 answers