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

NumberFormatException while trying to parse negative number for "ar_AE" locale

XMLWordPrintable

    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Mac OS
      JDK8

      A DESCRIPTION OF THE PROBLEM :
      NumberFormatException while trying to parse negative number for "ar_AE" locale

      Locale locale = new Locale("ar", "AE");
      NumberFormat format = NumberFormat.getInstance(locale);
      format.parse("-100.00"); --> Throws Exception

           [java] java.text.ParseException: Unparseable number: "-100.00"
           [java] at java.text.NumberFormat.parse(NumberFormat.java:385) ~[?:1.8.0_392]

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Locale locale = new Locale("ar", "AE");
      NumberFormat format = NumberFormat.getInstance(locale);
      System.out.println(format.parse("-100.00"));

      ACTUAL -
      java.text.ParseException: Unparseable number: "-100.00"

      ---------- BEGIN SOURCE ----------
      Locale locale = new Locale("ar", "AE");
      NumberFormat format = NumberFormat.getInstance(locale);
      System.out.println(format.parse("-100.00"));
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Catch exception and use Double.parseDouble to parse the value when locale is "ar_AE"

      FREQUENCY : always


            tongwan Andrew Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: