Set TimeZone at JVM always

If timezone is not set at the JVM level, then JVM would default to use operating system’s timezone. It’s not a recommended practice to use Operating System’s time zone for the  following reasons:

1. If your application is running across multiple data centers, say San Francisco, Chicago, Singapore – then JVMs in each data center would end up having different timezone. Thus JVMs in each data center would exhibit different behaviors. It would result in inconsistent results.

2. If you are deploying your application in cloud environment, applications could be moved to different data centers without your knowledge. In that circumstance also your application would end up producing different results.

3. Your own Operations team can also change the timezone, with out bringing to development team’s knowledge. It would also skew the results.

To avoid these commotion, it’s highly recommended to set timezone at the JVM.  user.timezone system property is used to set timezone for the JVM. Example if you want to set EDT timezone for your application, you would do:

-Duser.timezone=US/Eastern

One thought on “Set TimeZone at JVM always

Add yours

  1. Othet possible solution would be to design your app to store and commumicate with Date objects converted to UTC/GMT+0 And convert those objects to user’s local timezone when UI(or other) presentation is needed.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: