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

Java 11 Currency format for negative numbers (based on locale) not working.

XMLWordPrintable

    • 11
    • x86_64
    • windows_10

      ADDITIONAL SYSTEM INFORMATION :
      Java SE 11

      A DESCRIPTION OF THE PROBLEM :
      The currency format for US locale in Java 8 for negative numbers included the parenthesis, but in Java 11 the negative numbers do not have parenthesis anymore.

      Example: -$195.00 is displayed as ($195.00) in Java 8 where it is displayed as -195.00 in Java 11

      REGRESSION : Last worked in version 8u201

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      See attached sample program that was used to test on Java 8 vs. Java 11

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      -$195.00 is displayed as ($195.00) in Java 8 where it is displayed as -195.00 in Java 11
      ACTUAL -
      -$195.00 is displayed as ($195.00) in Java 8 where it is displayed as -195.00 in Java 11

      ---------- BEGIN SOURCE ----------
      import java.math.BigDecimal;
      import java.text.DecimalFormat;
      import java.text.NumberFormat;
      import java.util.Locale;

      public class NumFormat {

      public static void main(String[] args) {
      BigDecimal num = new BigDecimal(-10.00);
      NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US);
      DecimalFormat df = (DecimalFormat) DecimalFormat.getCurrencyInstance(Locale.US);
      System.out.println("the prefix is : " + df.getNegativePrefix());
      System.out.println("the numberformatted value : " + nf.format(num));
      System.out.println("the decimal formatted value " + df.format(num));

      }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No workaround

      FREQUENCY : always


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

              Created:
              Updated:
              Resolved: