Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java Timezone setDefault effects

following How to store date/time and timestamps in UTC time zone with JPA and Hibernate I want to set my application default time zone to UTC. My app runs on tomcat on a linux server along side some other apps. The server has other tomcat instances that run even more apps.

Will Timezone.setDefault(tz) affect the other apps on the same tomcat instance?

Will it affect other apps on other tomcat instances?

Is it possible to set the timezone only for the app? I loosely remember something about security manager settings to allow this.

like image 869
samz Avatar asked Mar 27 '12 14:03

samz


People also ask

What is TimeZone getDefault ()?

The getDefault() method of TimeZone class in Java is used to know the default TimeZone for this system or host. This may vary in according to the implementation in different environment. Syntax: public static TimeZone getDefault() Parameters: The method does not take any parameters.

How do I set the TimeZone in Java?

You can explicitly set a default time zone on the command line by using the Java system property called user. timezone . This bypasses the settings in the Windows operating system and can be a workaround.

What is UTC TimeZone in Java?

UTC stands for Co-ordinated Universal Time. It is time standard and is commonly used across the world. All timezones are computed comparatively with UTC as offset.

How does Java determine TimeZone?

By default, the JVM reads time zone information from the operating system. This information gets passed to the TimeZone class, which stores the time zone and calculates the daylight saving time. We can call the method getDefault, which will return the time zone where the program is running.


1 Answers

Would launching your app server with the java option -Duser.timezone=GMT do it for you?

like image 161
ms-tg Avatar answered Oct 19 '22 16:10

ms-tg