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

fr_FR NumberFormat.parse no longer recognizes U+00A0 as grouping seperator

    Details

      Description

      A DESCRIPTION OF THE PROBLEM :
      NumberFormat.getInstance(new Locale("fr", "FR")); no longer recognizes U+00A0 as a grouping character when parsing -- this is a regression from previous versions of java.

      REGRESSION : Last worked in version 12.0.1

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      see Temp.java source code below, along with expected vs actual results

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      hossman@tray:~/tmp$ java -version
      openjdk version "11.0.3" 2019-04-16
      OpenJDK Runtime Environment 18.9 (build 11.0.3+7)
      OpenJDK 64-Bit Server VM 18.9 (build 11.0.3+7, mixed mode)
      hossman@tray:~/tmp$ javac -version
      javac 11.0.3
      hossman@tray:~/tmp$ javac Temp.java
      hossman@tray:~/tmp$ java Temp
      ### locale = fr_FR
      ### input = 10898
      10898
      class java.lang.Long
      java.text.ParsePosition[index=5,errorIndex=-1]

      ### input = 10 898
      10898
      class java.lang.Long
      java.text.ParsePosition[index=6,errorIndex=-1]

      ### input = 10 898
      10898
      class java.lang.Long
      java.text.ParsePosition[index=6,errorIndex=-1]

      ### input = 10898,83491
      10898.83491
      class java.lang.Double
      java.text.ParsePosition[index=11,errorIndex=-1]

      ### input = 10 898,83491
      10898.83491
      class java.lang.Double
      java.text.ParsePosition[index=12,errorIndex=-1]

      ### input = 10 898,83491
      10898.83491
      class java.lang.Double
      java.text.ParsePosition[index=12,errorIndex=-1]

      ACTUAL -
      hossman@tray:~/tmp$ java -version
      openjdk version "13-ea" 2019-09-17
      OpenJDK Runtime Environment (build 13-ea+26)
      OpenJDK 64-Bit Server VM (build 13-ea+26, mixed mode, sharing)
      hossman@tray:~/tmp$ javac -version
      javac 13-ea
      hossman@tray:~/tmp$ javac Temp.java
      hossman@tray:~/tmp$ java Temp
      ### locale = fr_FR
      ### input = 10898
      10898
      class java.lang.Long
      java.text.ParsePosition[index=5,errorIndex=-1]

      ### input = 10 898
      10
      class java.lang.Long
      java.text.ParsePosition[index=2,errorIndex=-1]

      ### input = 10 898
      10
      class java.lang.Long
      java.text.ParsePosition[index=2,errorIndex=-1]

      ### input = 10898,83491
      10898.83491
      class java.lang.Double
      java.text.ParsePosition[index=11,errorIndex=-1]

      ### input = 10 898,83491
      10
      class java.lang.Long
      java.text.ParsePosition[index=2,errorIndex=-1]

      ### input = 10 898,83491
      10
      class java.lang.Long
      java.text.ParsePosition[index=2,errorIndex=-1]



      ---------- BEGIN SOURCE ----------
      import java.util.Locale;
      import java.text.NumberFormat;
      import java.math.RoundingMode;
      import java.text.ParsePosition;

      public final class Temp {
          public static void main(String[] args) throws Exception {
              final Locale fr_FR = new Locale("fr", "FR");
              System.out.println("### locale = " + fr_FR.toString());
              final NumberFormat fmt = NumberFormat.getInstance(fr_FR);
              fmt.setParseIntegerOnly(false);
              fmt.setRoundingMode(RoundingMode.CEILING);
              for (String input : new String[] { "10898",
                                                 "10 898", // NOTE: literal U+00A0 (NO-BREAK SPACE)
                                                 "10\u00A0898",
                                                 "10898,83491",
                                                 "10 898,83491", // NOTE: literal U+00A0 (NO-BREAK SPACE)
                                                 "10\u00A0898,83491" }) {
                  System.out.println("### input = " + input);
                  final ParsePosition pos = new ParsePosition(0);
                  final Number result = fmt.parse(input, pos);
                  System.out.println(result.toString());
                  System.out.println(result.getClass());
                  System.out.println(pos);
                  System.out.println();
              }
          }
      }

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

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                psonal Pallavi Sonal (Inactive)
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: