The timezone rules within Java compute nodes are delivered by means of the dedicated TZdata
package, comprised in each appropriate container. Follow the instructions below to:
Updating Timezone Data
Despite the fact the newest TZdata package edition is integrated into a node during its creation, after some time it becomes outdated due to periodical changing of the intrinsic data. Thus, old containers may require the corresponding updating from time to time (particularly, in order not to be recreated each time this is needed). For that, a special embedded TZUpdater tool is used, intended for keeping your timezone data accurate and up-to-date. It is fairly simple to use and can be run with a single-line command; you just need to:
1. Connect to your Java environment via SSH, e.g. using the embedded Web SSH
2. Once inside, you can check the currently used TZdata version by executing the following string:
java -jar /usr/java/utils/tzupdater.jar -V
3. If you’ve observed the corresponding package in the chosen container is outdated, you can update the timezone information using the embedded TZUpdater tool:
java -jar /usr/java/utils/tzupdater.jar -u
As you can see, getting the latest timezone package version for Java-powered server is a really simple operation with Jelastic.
Now, let’s discover how to check and change the application server’s local time - we’ll consider this on the example of a Tomcat 9 server.
1. Let’s set the current timestamp to be shown at the server start page - this will help to quickly ensure that new timezone settings have been successfully applied and are relevant for now.
For that, paste the code below instead of the /opt/tomcat/webapps/ROOT/index.jsp file default content (the easiest way is to use the inbuilt Jelastic File Manager for that).
the changes and Open
your environment in browser
with the corresponding button to see the current server time, like:
3. In order to change the actual timezone for a particular server, perform the following:
Switch to the variables.conf configuration file and add the -Duser.timezone variable with the required zone as a value, for example:
Note: Depending on a particular application server used, the location of this file may vary:
- Tomcat 7, 8, 9, TomEE - /opt/tomcat/conf/variables.conf
- Jetty 9 - /opt/jetty/etc/variables.conf
- Payara 4, 5 - /opt/payara/glassfish/domains/domain1/config/variables.conf
- Spring Boot 1, 2 - /opt/shared/conf/variables.conf
Access the GF admin panel, go to the Configurations > gfcluster-config (
for GF 4) > JVM Settings > JVM Options
section and click the Add JVM Option
button. Paste the corresponding string (e.g. -Duser.timezone=US/Pacific
) within the appeared input field:
Switch to the /opt/wildfly/bin/standalone.conf file (or, if a server was scaled horizontally, refer to the /opt/wildfly/bin/domain.conf config) and declare the corresponding variable using the following format:export JAVA_OPTS="-Duser.timezone=US/Pacific"
4. Save the made adjustment and Restart your application server in order to apply new settings.
Now, just refresh the server start page or click Open in Browser
again to see the updated local time:
new rules were applied successfully. In such a way, you can set any desired time location for your server without any problems, in a matter of minutes.