Closed aileftech closed 11 months ago
Yes as I understand it with Postgresql the timestamp with timezone
and timestamp without timezone
types (which both map to OffsetDateTime
and LocalDateTime
in JDBC respectively) are stored identically in the database, just the times are interpreted differently when they're stored so that the ones with timezones are converted to UTC.
If you need to store the actual timezone you're supposed to add that as a separate column yourself, eg a text
column that might store Europe/London
or +02:00
which you'd apply to the OffsetDateTime
when you read it.
In my case I'm effectively using it as an Instant
(which isn't directly supported by the Postgres JDBC driver) and applying any timezone adjustments myself. I need to use OffsetDateTime
as my entity type as LocalDateTime
doesn't support adding a timezone to it.
Thanks again for your help. This shouldn't be too hard to implement as it will then effectively be the same as the LocalDateTime implementation. I expect to have this online in the next few days, along with #9 so that unsupported types don't completely stop the application from running, but rather run with limited functionality on those specific entities.
Can't wait to try it properly! The admin UI is definitely a feature of Django I miss when working on Spring Boot apps.
Fixed in main
! Will deploy on Maven in the next few days to add some more stuff before release.
Released 0.1.5
on Maven, so I believe you can finally give it a try in the next few days. I hope it runs fine this time; any other issue, please let me know!
I forgot to come back and mention that the changes are all working for me now!
Hey @agxs, I've been experimenting a bit with OffsetDateTime but I have a few doubts. From what I'm seeing, a OffsetDateTime field is still stored as a datetime without any offset at the database level. I've tested this in MySQL but from what I've read is the same in PostgreSQL.
So I wanted to ask you if I'm understanding correctly and it's the same in your use case, or if you are using something else to store the offset as well. In the previous case the offset is always zero, so it is trivial to add support for OffsetDateTime because it's just a normal date time basically. But from what I understood there's no standardized solution to store the offset at the db level so supporting that would be hard.