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

Name of UTC timezone in a locale changes depending on previous code

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      b01
    • Introduced In Version:
    • Resolved In Build:
      b27
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        ADDITIONAL SYSTEM INFORMATION :
        $ uname -a
        Linux gonzo 5.10.0-8-amd64 #1 SMP Debian 5.10.46-4 (2021-08-03) x86_64 GNU/Linux
        $ java -version
        openjdk version "17" 2021-09-14
        OpenJDK Runtime Environment (build 17+35-Debian-1)
        OpenJDK 64-Bit Server VM (build 17+35-Debian-1, mixed mode, sharing)

        A DESCRIPTION OF THE PROBLEM :
        Name of timezone UTC in locale 'zh-MO' according to JDK is 協調世界時間. However, if an unrelated code (requesting the name in a different, though related, locale) is executed first, name changes to 世界標準時間.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Compile and run the short attached program like this:
        $ javac test.java && java test && java test broken

        Observe that the name in the same locale changes between two runs.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        zh-MO: 協調世界時間

        zh-Hant-HK: 世界標準時間
        zh-MO: 協調世界時間

        ACTUAL -
        zh-MO: 協調世界時間

        zh-Hant-HK: 世界標準時間
        zh-MO: 世界標準時間


        ---------- BEGIN SOURCE ----------
        import java.time.*;
        import java.time.format.*;
        import java.util.*;

        public class test
        {
            public static void main (String[] args) throws Exception
            {
                if (args.length == 1 && args[0].equals ("broken"))
                    System.out.println (utcNameIn ("zh-Hant-HK"));
                System.out.println (utcNameIn ("zh-MO"));
                System.out.println ();
            }

            protected static String utcNameIn (String locale)
            {
                return locale + ": " + DateTimeFormatter.ofPattern ("zzzz", Locale.forLanguageTag (locale)).format (ZonedDateTime.ofInstant (Instant.ofEpochSecond (0), ZoneId.of ("UTC")));
            }
        }

        ---------- END SOURCE ----------

        FREQUENCY : always


          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  Created:
                  Updated:
                  Resolved: