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

j.t.SimpleDateFormat.getDateFormatSymbols().getZoneStrings() returns incorrect result for some time zones

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b120
    • Verification:
      Verified

      Description

      Minimized test:
      ----------------------------------------------------------

      for (String tzID : TimeZone.getAvailableIDs()) {
          TimeZone tz = TimeZone.getTimeZone(tzID);
          TimeZone.setDefault(tz);
          SimpleDateFormat sdf = new SimpleDateFormat("z");
          if (!Arrays.stream(sdf.getDateFormatSymbols().getZoneStrings()).anyMatch(
                          zone -> tzID.equalsIgnoreCase(zone[0]))) {
              System.out.println("Time zone ID: " + tzID);
          }
      }
      ----------------------------------------------------------

      The output will be (for 9 - for earlier affected versions the output can differ but it will also contains time zones):
      ----------------------------------------------------------
      Time zone ID: Asia/Urumqi
      Time zone ID: Etc/GMT
      Time zone ID: Etc/GMT+0
      Time zone ID: Etc/GMT+1
      Time zone ID: Etc/GMT+10
      Time zone ID: Etc/GMT+11
      Time zone ID: Etc/GMT+12
      Time zone ID: Etc/GMT+2
      Time zone ID: Etc/GMT+3
      Time zone ID: Etc/GMT+4
      Time zone ID: Etc/GMT+5
      Time zone ID: Etc/GMT+6
      Time zone ID: Etc/GMT+7
      Time zone ID: Etc/GMT+8
      Time zone ID: Etc/GMT+9
      Time zone ID: Etc/GMT-0
      Time zone ID: Etc/GMT-1
      Time zone ID: Etc/GMT-10
      Time zone ID: Etc/GMT-11
      Time zone ID: Etc/GMT-12
      Time zone ID: Etc/GMT-13
      Time zone ID: Etc/GMT-14
      Time zone ID: Etc/GMT-2
      Time zone ID: Etc/GMT-3
      Time zone ID: Etc/GMT-4
      Time zone ID: Etc/GMT-5
      Time zone ID: Etc/GMT-6
      Time zone ID: Etc/GMT-7
      Time zone ID: Etc/GMT-8
      Time zone ID: Etc/GMT-9
      Time zone ID: Etc/GMT0
      Time zone ID: GMT0
      ----------------------------------------------------------

      This minimized test shows that there are a number of time zones that have names but their IDs are not presented in zone strings of date format.

        Attachments

          Activity

            People

            Assignee:
            nishjain Nishit Jain
            Reporter:
            evotchen Elena Votchennikova (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: