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

MessageFormat::toPattern() returns a different style than expected in JDK23 for Chinese Locale

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not an Issue
    • Icon: P3 P3
    • None
    • 23
    • core-libs

      It's more of a clarification issue to understand the behavioral difference for MessageFormat::toPattern() between JDK 22 vs JDK23 w.r.to Chinese Locale.

      One of the old test in JCK failing in 23 when run with Non English Windows (LOCALE=zh_CN) , for more details - https://bugs.openjdk.org/browse/JCK-7321556

      This test was OK in 22, but failing in 23.

      I understand the toPattern() behavior varies based on Locale.

      But this specific case where the format style is explicitly specified looks not honored in JDK23. Please see the stand alone code attached
      ===
       String initPattern = "{3,number,0.0}";
              MessageFormat mf = new MessageFormat(initPattern);
              Format formatter = DateFormat.getDateInstance(DateFormat.MEDIUM);
              mf.setFormat(0, formatter);
              String newPattern = mf.toPattern();
              out.println("The pattern is " + newPattern);
              String expPatterns[] = {"{3,date}", "{3,date,medium}"};
      ...
      ===

      Run results : JDK 22 the test is OK, in JDK 23 it's failing.
      ===
      C:\Diffs>C:\Project\JDK-22\b25\jdk-22\bin\java -Duser.language=zh ToPattern_InChineseLocale
      The pattern is {3,date}
      OK

      C:\Diffs>C:\Project\JDK-23\b25\jdk-23\bin\java.exe -Duser.language=zh ToPattern_InChineseLocale
      The pattern is {3,date,long}
      New pattern is not one of the expected one: new Pattern is : {3,date,long} Expected Patterns : [{3,date}, {3,date,medium}]

            jlu Justin Lu
            kganapureddy Krushnareddy Ganapureddy
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: