-
Bug
-
Resolution: Fixed
-
P3
-
1.1.4
-
1.1.6
-
sparc
-
solaris_2.5
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2017471 | 1.2.0 | John Oconner | P3 | Resolved | Fixed | 1.2beta3 |
Name: dfC67450 Date: 10/19/97
The java.text.DecimalFormat.DecimalFormat(String pattern,
DecimalFormatSymbols symbols) constructor should clone second parameter
using setDecimalFormatSymbols() method not just store the reference.
(see Javadoc for DecimalFormat.setDecimalFormatSymbols() method:
Sets the decimal format symbols, which is generally not changed
by the programmer or user.
)
Here is the test demonstrating the bug:
-----------------Test.java------------------------
import java.text.*;
public class Test {
public static void main (String args[]){
DecimalFormatSymbols symbols = new DecimalFormatSymbols();
DecimalFormat df = new DecimalFormat("#,##0.0", symbols);
long n = 123;
System.out.println("format(" + n + ") = " +
df.format(n, new StringBuffer(), new FieldPosition(0)));
symbols.setDecimalSeparator('p'); // change value of field
System.out.println("format(" + n + ") = " +
df.format(n, new StringBuffer(), new FieldPosition(0)));
}
}
---------Output from the test---------------------
format(123) = 123.0
format(123) = 123p0
--------------------------------------------------
======================================================================
- backported by
-
JDK-2017471 java.text.DecimalFormat.DecimalFormat(String, DecimalFormatSymbols) works wrong
- Resolved