[PATCH] Fix handling of negative suffix in DecimalFormat

"Guillermo Rodriguez" <[email protected]> Fri, 30 Jan 2015 14:28:30 +0100
Newsgroups gmane.comp.java.classpath.devel
Message-ID <[email protected]>
When a negative subpattern is not explicitly defined,
DecimalFormat was not using the positive suffix for
negative values.

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

---
 java/text/DecimalFormat.java |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/java/text/DecimalFormat.java b/java/text/DecimalFormat.java
index 77af0d3..5e4bf76 100644
--- a/java/text/DecimalFormat.java
+++ b/java/text/DecimalFormat.java
@@ -1371,6 +1371,7 @@ public class DecimalFormat extends NumberFormat
     else
       {
         this.positiveSuffix = buffer.toString();
+        this.negativeSuffix = positiveSuffix;
       }
 
     return i;
-- 
1.7.0.4