Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I programmatically set the time zone in Java?

Tags:

java

timezone

I know I can feed VM arguments as follows

-Duser.timezone="Australia/Sydney"

Is there a programmatic way to do the equivalent? I would like the setting to be applied across the entire virtual machine.

like image 822
deltanovember Avatar asked Oct 03 '11 03:10

deltanovember


1 Answers

java.util.TimeZone.setDefault() can be used to set a default time zone to be returned by getDefault().

like image 183
MetroidFan2002 Avatar answered Oct 22 '22 18:10

MetroidFan2002