HomePage » Java » CoreJava » JavaTimezone


Java timezone problem under linux


In case Java is not detecting the correct timezone settings on you Linux OS, try the followings:

1. Determine the system timezone
ls -l /etc/localtime


2. Adding a $TZ variable to /etc/profile. Use the timezone return by the last command.
export TZ="GMT"


or one may also change the timezone in Java code
TimeZone.setDefault(TimeZone.getTimeZone("US/Eastern"))


or by command argument
-Duser.timezone=US/Eastern
Comments [Hide comments/form]
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki