We're updating the issue view to help you get more done. 

No negative sign if negative subpattern is empty

Description

In my new code, patterns ending in ';' are seen as having an empty negative subpattern. In this case, my code treats negative numbers as if they have no prefix or suffix, causing the implicit minus sign from not being displayed.

Code:

1 2 3 4 5 6 7 try { DecimalFormat df = new DecimalFormat("#,##0;"); System.out.println(df); System.out.println(df.format(-12345)); } catch (IllegalArgumentException e) { System.out.println(e); }

ICU 58 behavior:

1 2 com.ibm.icu.text.DecimalFormat@674dc -12,345

ICU 59 behavior:

1 2 com.ibm.icu.text.DecimalFormat@fffef8ee { symbols@1073a groupingSize:3 maximumFractionDigits:0 minimumFractionDigits:0 minimumIntegerDigits:1 negativePrefixPattern: negativeSuffixPattern: positivePrefixPattern: positiveSuffixPattern: } 12,345

'''My opinion:''' Patterns with a trailing ';' are most likely mistakes. Therefore this is not a regression we should worry about. Alternatively, we could throw an exception if the negative subpattern is empty.

GoogleIssue:37158085

Status

Assignee

Shane Carr

Reporter

Shane Carr

Components

Fix versions

Priority

assess