How To Set TimeZone in Java

You can set timezone for many common programs like Java or MySQL server. And of course you can do it with JVM. JVM Host clients can set timezone with our custom JVM control panel JVMCP. Timezone can also be set directly in shell variable or as Java command line parameter. Here is how to set timezone in Java

A. Set TimeZone in Java by Programming

TimeZone.setDefault(TimeZone.getTimeZone("Japan"));

B. Set TimeZone by Command Line

java -Duser.timezone="America/New_York" MainClass

C. Set TimeZone by Environment (for login user)

# for all processes run in current shell
export TZ="IST"
# for all applications using JVM
export JAVA_OPTS="-Duser.timezone=Europe/Budapest"

Comments

Popular posts from this blog

Reduce TIME_WAIT Socket Connections