2 Replies Latest reply on Dec 11, 2015 4:15 PM by arnab_ghosh Branched to a new discussion.

    Problem with default timezone on WildFly - standalone

    pmarek

      We need to store dates in UTC in our webapp, so I changed standalone XML and added default java system parameter user.timezone with value UTC.

      But there is a problem, because when I deploy webapp to WildFly in standalone mode, TimeZone.getDefault() always return CET. But when I deploy same webapp to the same WildFly in domain mode, everything works perfect and TimeZone.getDefault() return UTC.

      How is it possible? I wrote simple webapp as example of this behavior:

       

      index.jsp:

      <%@page import="java.util.TimeZone"%>

      <html>

      <body>

      <h2>Default TimeZone</h2><%= TimeZone.getDefault().getDisplayName() %>

      <h2>user.timezone</h2><%= System.getProperty("user.timezone") %>

      </body>

      </html>

       

      web.xml:

      <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" >
      <web-app>
        <display-name>TimeZone test</display-name>
      </web-app>
      
      

       

      pom.xml:

      <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <groupId>cz.pm2k</groupId>
        <artifactId>TimeZoneTest</artifactId>
        <packaging>war</packaging>
        <version>0.0.1-SNAPSHOT</version>
        <name>TimeZoneTest Maven Webapp</name>
      
        <build>
          <finalName>TimeZoneTest</finalName>
        </build>
      </project>
      
      

       

      I also add this piece of configuration to standalone.xml and domain.xml in wildfly directory:

      <system-properties>
          <property name="user.timezone" value="UTC"/>
      </system-properties>
      

       

      All sources and WAR are in attachment.