Md.
Md.

Reputation: 526

Java Tomcat Application is Saving Timestamp to the Database in Wrong Timezone

In a Java Tomcat application, I am using -Duser.timezone=Canada/Central. Also, I setup server timezone to Canada/Central. However, when I save timestamp to the database, using LocalDateTime.now(), the UTC timestamp is being saved to the database.

Anyone has idea what's going wrong?

Thanks.

Upvotes: 0

Views: 130

Answers (1)

Md.
Md.

Reputation: 526

I think, I found an elegant solution.

In jdbc connection string, adding the following parameters:

useLegacyDatetimeCode=false&serverTimezone=America/Winnipeg

Upvotes: 2

Related Questions