The method java.text.DecimalFormat.getMaximumIntegerDigits() returns INTEGER.MAX_VALUE while the spec states that return value should be at last 309:
======
Gets the maximum number of digits allowed in the integer portion of a number. For formatting numbers other than BigInteger and BigDecimal objects, the lower of the return value and 309 is used.
======
You may reproduce it using following program:
import java.text.DecimalFormat;
public class T {
public static void main(String[] args) {
DecimalFormat df = new DecimalFormat();
String patterns[] = {"000.00", "###0.###", "##,###.0", "000,000.000", "prefix#suffix", "prefix", "#0,00000.00;00.0" };
for (int i = 0; i < patterns.length; i++) {
df.applyPattern(patterns[i]);
System.out.println("applyPattern(String pattern) fails with pattern \"" + patterns[i] + "\"");
System.out.println(" getMaximumIntegerDigits() returns " + df.getMaximumIntegerDigits());
}
}
}
======
Gets the maximum number of digits allowed in the integer portion of a number. For formatting numbers other than BigInteger and BigDecimal objects, the lower of the return value and 309 is used.
======
You may reproduce it using following program:
import java.text.DecimalFormat;
public class T {
public static void main(String[] args) {
DecimalFormat df = new DecimalFormat();
String patterns[] = {"000.00", "###0.###", "##,###.0", "000,000.000", "prefix#suffix", "prefix", "#0,00000.00;00.0" };
for (int i = 0; i < patterns.length; i++) {
df.applyPattern(patterns[i]);
System.out.println("applyPattern(String pattern) fails with pattern \"" + patterns[i] + "\"");
System.out.println(" getMaximumIntegerDigits() returns " + df.getMaximumIntegerDigits());
}
}
}
- csr for
-
JDK-8324176 API doc for DecimalFormat::getMaximumIntegerDigits is unclear
-
- Closed
-