My application uses Database-per-tenant multitenancy, and each tenant has a timezone.
I don't want to use Timestamp as I don't want the database handling the timezone translation, but what I would like to do is convert between ZonedDateTime and MySQL DateTime.
In my application, I retrieve the current time for the tenant like so :
ZonedDateTime.of(LocalDateTime.now(), tenant.getTenantZoneId());
I want to write this to the database as the zoned date time would show it (i.e. with the timezone and DST applied).
Upon reading from the database, this transformation shouldn't be necessary, and I can just assume the timezone for all datetimes.
How can I do that initial translation? And how can I do this in a nice way a JPA provider (especially hibernate)