In any webapplication, the timestamps and zones play an important role. Any discrepancies to fetch and save time details normally occur in terms of zones result in deep confusion to the user. This requires us to strategise the way we handle this sort of information.
It is a good practice to maintain the single timezone at application level to avoid any such issues.
How to configure Uniform Timezone:
There are 3 stages Timezone information might change - Middleware, Frontend and Database. As long as it is controlled at middleware layer, the frontend is free to convert and render the data according to user's locale. Since the database server has its own timezone configuration, we have to force it to ignore those details and save what the middleware sends.
Config at middleware:
1. Since any java based application or web servers work as per JVM's timezone. Pass timezone information as the jvm arguments.
2. If using Hibernate 5.3 or higher with Spring, following parameter need to be updated in spring-bean configuration file
UTC
3. Forcing database to ignore its own configuration:
Eg: MySQL: Put the following parameters in the connection string
It is a good practice to maintain the single timezone at application level to avoid any such issues.
How to configure Uniform Timezone:
There are 3 stages Timezone information might change - Middleware, Frontend and Database. As long as it is controlled at middleware layer, the frontend is free to convert and render the data according to user's locale. Since the database server has its own timezone configuration, we have to force it to ignore those details and save what the middleware sends.
Config at middleware:
1. Since any java based application or web servers work as per JVM's timezone. Pass timezone information as the jvm arguments.
2. If using Hibernate 5.3 or higher with Spring, following parameter need to be updated in spring-bean configuration file
3. Forcing database to ignore its own configuration:
Eg: MySQL: Put the following parameters in the connection string
No comments:
Post a Comment