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

NumberFormat.getPercentInstance().parse(String) does not work in Java 9

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "9"
      Java(TM) SE Runtime Environment (build 9+179)
      Java HotSpot(TM) Server VM (build 9+179, mixed mode, emulated-client, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 10.0.14393]

      A DESCRIPTION OF THE PROBLEM :
      NumberFormat.getPercentInstance().parse(String) can not parse a percent value.

      REGRESSION. Last worked in version 8u152

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the test program.


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "main" java.text.ParseException: Unparseable number: "75%"
              at java.base/java.text.NumberFormat.parse(Unknown Source)
              at TestJava9.main(TestJava9.java:7)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.text.NumberFormat;
      import java.text.ParseException;

      public class TestJava9 {

          public static void main( String[] args ) throws ParseException {
              double value = NumberFormat.getPercentInstance().parse( "75%" ).doubleValue();
              System.out.println( value );
          }
      }
      ---------- END SOURCE ----------

            nishjain Nishit Jain
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: