How can I set the time zone of H2 database? I'm using Hibernate for creating the database.
Apparently you don't have a parameter on the connection but the database will use the timezone of the JVM where the driver is loaded so you can set -Duser. timezone=UTC . Note that you can't change the timezone after the driver has been loaded.
Timezone as a URL Paramspring: datasource: url: jdbc:mysql://localhost:3306/test?connectionTimeZone=UTC username: root password: Also, we can, of course, configure the datasource with Java configuration instead.
The format is hh:mm:ss[. nnnnnnnnn].
H2 Database Engine is the in-memory database for your automated tests. H2 Database Engine is primarily used for running application test cases by our development team.
EDIT: I found out my answer is probably incorrect, misleading at the very least. I tried to delete it, but apparently it is not possible.
Please see instead: How to store date/time and timestamps in UTC time zone with JPA and Hibernate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With