Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8345213

JVM Prefers /etc/timezone Over /etc/localtime on Debian 12

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      Java Version: OpenJDK 17 & 21
      OS: Debian GNU/Linux 12 (bookworm)

      A DESCRIPTION OF THE PROBLEM :
      In recent versions of Debian (starting with Debian 12), the system no longer relies on /etc/timezone for timezone management. Instead, Debian and systemd have transitioned to using /etc/localtime as the authoritative source for timezone data. However, OpenJDK still prioritizes /etc/timezone when determining the system timezone, leading to inconsistencies between the system's timezone and the default timezone for the JVM.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Set the system timezone using timedatectl: "sudo timedatectl set-timezone Europe/Paris"
      2. Check /etc/localtime and /etc/timezone: "ls -l /etc/localtime; cat /etc/timezone"
          Observe that /etc/localtime points to /usr/share/zoneinfo/Europe/Paris, but /etc/timezone has not been updated.
      3. Run a simple Java application and retrieve the default timezone:

          System.out.println(java.util.TimeZone.getDefault());
       
          Observe that the JVM reports the timezone from /etc/timezone

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Java should use /etc/localtime as the primary source for determining the system timezone, consistent with Debian’s new standard.
      ACTUAL -
      Java uses /etc/timezone, causing mismatches between the system timezone and the JVM timezone.

      CUSTOMER SUBMITTED WORKAROUND :
      Explicitly specifying the timezone with the "TZ" variable or "-Duser.timezone" JVM option.

      or

      Manually updating /etc/timezone after changing the systems timezone with "timedatectl":
      timedatectl show --value --property=Timezone | sudo tee /etc/timezone

      FREQUENCY : always


            naoto Naoto Sato
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: