JDK-8221245 : Java 11 Currency format for negative numbers (based on locale) not working.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.text
  • Affected Version: 11
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_10
  • CPU: x86_64
  • Submitted: 2019-03-19
  • Updated: 2019-10-02
  • Resolved: 2019-04-02
Related Reports
Duplicate :  
Description
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



Comments
As this is an issue which is being handled with JDK-8215181, closing as duplicate of that bug.
02-04-2019

Accounting style (negative number in parens) will be supported with JDK-8215181.
21-03-2019