ingelabs / classpath

GNU Classpath, Essential Libraries for Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Negative suffix not properly handled in DecimalFormat

ingebot opened this issue · comments

Note: this issue was migrated automatically using bugzilla2github

Original bug ID: BZ#70658
From: @guillerodriguez
Reported version: 0.99

Comment author: @guillerodriguez

When a negative subpattern is not explicitly defined, DecimalFormat should use the "positive suffix" for negative values as well.

Simple test case to reproduce the problem:

DecimalFormat tempFormat = new DecimalFormat("0.0 unit");
System.out.println(tempFormat.format(4.3));
System.out.println(tempFormat.format(-4.3));

Yields:

4.3 unit
-4.3

Should be:

4.3 unit
-4.3 unit

Comment author: @guillerodriguez

Created attachment 38264
Proposed fix

Here's a patch that fixes the problem. First reported to GNU Classpath mailing list in January 2015.

Attached file: file_70658.txt (text/plain, 257 bytes)
Description: Proposed fix