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

Unable to implement workaround to JDK-4510618 bug with java 9 => Unable to parse french numbers

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "9.0.1"
      Java(TM) SE Runtime Environment (build 9.0.1+11)
      Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 10

      A DESCRIPTION OF THE PROBLEM :
      JDK-4510618 describes the initial problem that affects all jdk version : JDK is not able to parse french numbers because it uses non breaking spaces as separators. The workaround suggested in the bug report doesn't work with JDK 9.

      REGRESSION. Last worked in version 8u162

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Execute the provided Junit test




      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Test should not fail
      ACTUAL -
      Test fails

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import static org.junit.Assert.*;

      import java.text.DecimalFormat;
      import java.text.DecimalFormatSymbols;
      import java.text.NumberFormat;
      import java.text.ParseException;
      import java.util.Locale;

      import org.junit.Test;

      public class CurrencyWidgetTest {
      private static final char NON_BREAKING_SPACE = 160;
      private static final char SPACE = ' ';

      @Test
      public void basicJDKtest() throws ParseException {
      DecimalFormat format = (DecimalFormat)NumberFormat.getCurrencyInstance(Locale.FRANCE);
      DecimalFormatSymbols decimalFormatSymbols = format.getDecimalFormatSymbols();
      if (decimalFormatSymbols.getGroupingSeparator()==NON_BREAKING_SPACE) {
      decimalFormatSymbols.setGroupingSeparator(SPACE);
      }
      if (decimalFormatSymbols.getDecimalSeparator()==NON_BREAKING_SPACE) {
      decimalFormatSymbols.setDecimalSeparator(SPACE);
      }
      format.setDecimalFormatSymbols(decimalFormatSymbols);

      String text = "5 000,00 €";
      Number parse = format.parse(text);
      assertNotNull(parse);
      }
      }
      ---------- END SOURCE ----------

            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: