<p>I have a Spring Boot application that's running on Kubernetes. The image was built with the <code>spring-boot:build-image</code> Maven goal.</p>
<p>I pass timezone information to the container in the deployment.yml file using</p>
<pre><code>  volumes:
    - name: tz-rome
      hostPath:
        path: /usr/share/zoneinfo/Europe/Rome
  containers:
    - name: ***
      image: ***
      volumeMounts:
        - name: tz-rome
          mountPath: /etc/localtime
</code></pre>
<p>And when I try to run <code>date</code> from the running container, the result is correct:</p>
<pre><code>$ date
Fri Jul 23 10:11:54 CEST 2021
</code></pre>
<p>But the Spring application logs and the timestamps are two hours early (so, in this case, <code>8:11:54</code>).</p>
<p>Explicitly passing the JAVA_OPTS with the current time zone in the k8s deployment.yml file like this:</p>
<pre><code>env:
  - name: JAVA_OPTS
    value: &quot;-Duser.timezone=CEST&quot;
</code></pre>
<p>slightly improves the situation, now the timestamps are only one hour early, but it's still not OK, I need the current time.</p>
<p>How can I fix this?</p>

user1527576
<p>The solution was easier than I thought.</p>
<p><code>CEST</code> is not a <a href="https://en.wikipedia.org/wiki/List_of_tz_database_time_zones" rel="nofollow noreferrer">valid time zone name</a>, even if it's present in the <code>date</code> command output. By using <code>Europe/Rome</code>, everything now works.</p>
