Name: dfC67450 Date: 04/07/2000
The accessor methods in the public API set and get the grouping
size as an 'int'. However internal representation is a 'byte'.
This means that values outside of the byte range are narrowed.
Source for DecimalFormat.setGroupingSize:
public void setGroupingSize (int newValue) {
groupingSize = (byte)newValue;
}
Here is the test demonstrating the bug:
-----------------Text.java------------------------
import java.text.*;
public class Text {
public static void main(String args[]) {
DecimalFormat df = new DecimalFormat();
int value = 200;
df.setGroupingSize(value);
int newValue = df.getGroupingSize();
if (value != newValue) {
System.out.println("setGroupingSize(" + value + ")");
System.out.println("getGroupingSize() returns " + newValue);
System.out.println("Test failed");
} else
System.out.println("Test passed");
}
}
--------- Output from the test ---------------------
setGroupingSize(200)
getGroupingSize() returns -56
Test failed
-------------------------------------------------
======================================================================