Kuba Petržílka
02/15/2021, 8:37 AMtimestamptz
in postgres I used timstamp(...)
(Column<Instant>
from Java Time API extension for Exposed) and when I persist a record it uses my current timezone, but I would like to get it persisted in GMT so that I dont have to do that math when comparing the values while looking into the DB (I want 2021-02-14 15:06:07.66052+00
instead of 2021-02-14 16:06:07.66052+01
) how do I enforce this?spand
02/15/2021, 9:28 AMTimeZone.setDefault(TimeZone.getTimeZone("UTC"))
Kuba Petržílka
02/15/2021, 9:39 AM@PostConstruct
method in a configuration class (I m using spring boot) and it doesn't seem to have any effectJoel
02/16/2021, 4:57 PMtimestampz
specifically yet. The effect you're seeing is probably related to serialization of the data. See here, my guess is your db is assigning the default timezone.Kuba Petržílka
02/16/2021, 5:48 PM13: DateTimeFormatter.ISO_LOCAL_DATE.withLocale(Locale.ROOT).withZone(ZoneId.systemDefault())
And the suggestion to change the default timezone doesn't work in my case.. but I think it is not a good option anyway.. I d like to choose which timezone I want to use per record not globaly per system ... so Exposed really lacks this supportJoel
02/16/2021, 6:58 PMspand
02/16/2021, 8:32 PMjava.sql.Timestamp
to the database. I cant see any way around that other than maybe having something per dialect that sets the zone per connection.Kuba Petržílka
02/17/2021, 2:49 PM