简体   繁体   中英

How to maintain a unique timezone across web application

I have requirement in my enterprise web application to maintain a unique time zone (say EST). All the timestamp what we display and store in database should be in EST only. I am using Spring MVC/Hibernate for my web application. Is there any best practices or suggestion how to implement this feature? Any suggestions or guidance would be of great help.

My suggestion is to set the timezone in the initialization script which creates the java process using the argument -Duser.timezone=NAME where NAME you can find in the list below:

https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

Note1: Unfortunately, the developer can create some objects like Calendar using a different TimeZone. For those cases you can use Java Security Polices (it will be hard to setup for a application server). But I think just configuring that is pretty enough.

Note2 : By default the JVM collects the timezone from the user environment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM