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

Default timezone should return zone ID if /etc/localtime is valid but not canonicalization on linux

XMLWordPrintable

      When the /etc/localtime is a symlink and non-standard path, like "../usr/share/zoneinfo//Asia/Shanghai", default timezone return GMT. But we expect it to return zone ID.

      This can be reproduced in the following way.

      rm -rf /etc/localtime
      ln -s ../usr/share/zoneinfo//Asia/Shanghai /etc/localtime

      ${TEST_JDK}/bin/java TestTimeZone

      TestTimeZone source:
      ---------- BEGIN SOURCE ----------
      import java.util.*;

      public class TestTimeZone {
         public static void main(String args[])
         {
             TimeZone time_zone_default = TimeZone.getDefault();

             System.out.println("Default TimeZone: " + time_zone_default);
         }
      }
      ---------- END SOURCE ----------

      EXPECTED
      Default TimeZone: sun.util.calendar.ZoneInfo[id="Asia/Shanghai",offset=28800000,dstSavings=0,useDaylight=false,transitions=31,lastRule=null]

      ACTUAL
      Default TimeZone: sun.util.calendar.ZoneInfo[id="GMT+08:00",offset=28800000,dstSavings=0,useDaylight=false,transitions=0,lastRule=null]

            wuyan Wu Yan
            wuyan Wu Yan
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: