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

Wrong NegativePrefix in (DecimalFormat) NumberFormat for Locale.NO

XMLWordPrintable

      ADDITIONAL SYSTEM INFORMATION :
      MacOs 10.14 / Jdk 10.0.2

      A DESCRIPTION OF THE PROBLEM :
      When getting the DecimalFormat for Locale NO, and some others, then ((DecimalFormat) NumberFormat.getNumberInstance(new Locale("no"))).getNegativePrefix() returns Unicode Character 'MINUS SIGN' (U+2212). While most other Locale use Unicode Character 'HYPHEN-MINUS' (U+002D).

      REGRESSION : Last worked in version 8u191

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
       public void norwegianNegativePrefixWrong() throws UnsupportedEncodingException {
              String norwegianNegativePrefix = ((DecimalFormat) NumberFormat.getNumberInstance(new Locale("no"))).getNegativePrefix();
              String englishNegativePrefix = ((DecimalFormat) NumberFormat.getNumberInstance(new Locale("en"))).getNegativePrefix();
              if (norwegianNegativePrefix.equals(englishNegativePrefix)) {
                  System.out.println("Negative prefix is similar");
              } else {
                  System.out.println("Negative prefix is not similar");
              }
          }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Negative prefix is similar
      ACTUAL -
      Negative prefix is not similar

      CUSTOMER SUBMITTED WORKAROUND :
      After getting DeicmalFormat you can manually set negative prefix, i.e.

      DecimalFormat df = ((DecimalFormat) NumberFormat.getNumberInstance(new Locale("no")));
      df.setNegativePrefix("-");

      FREQUENCY : always


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

              Created:
              Updated:
              Resolved: