×
×

Knowledgebase & Downloads

The knowledgebase provides documentation written by our team. Please select a category or search for answers.

Articles

How can I change time and timezone on my Java VPS?

To change timezone (this will also change your system time accordingly) please login to your VPS as root and remove /etc/localtime file:

[root@javahost ~]# rm -f /etc/localtime

Then you can list available timezones from /usr/share/zoneinfo

[root@javahost ~]# ls /usr/share/zoneinfo

and link the one you prefer to /etc/localtime.

Now an example. Say, you want Portugal time.

Before the change:
[root@javahost ~]# date
Thu Jul 18 19:13:08 UTC 2013

Make the change by running:
[root@javahost ~]# rm -f /etc/localtime
[root@javahost ~]# ln -s /usr/share/zoneinfo/Portugal /etc/localtime

Check time now
[root@javahost ~]# date
Thu Jul 18 20:14:26 WEST 2013

You may also reboot the VPS so that all services cleanly pick up new time.
The above method will also change you JVM/Java default time unless you modify it as given below.

JVM/Java being a virtual machine itself has its own timezone setting using user.timezone parameter.
On shared host (with private JVM) you can select needed timezone in Java Control Panel.
On a VPS just modify JAVA_OPTS environment variable in your .bashrc for the account java is running on by adding user.timezone parameter there. For example:

export JAVA_OPTS="-Xms128m -Xmx256m -XX:MaxPermSize=256m -Duser.timezone=GMT-6 -Duser.country=MX -Duser.language=es -Djava.awt.headless=true"


Powered by HostBill