public final static NumberFormat getpercentInstance()
should be
public final static NumberFormat getPercentInstance()
On p. 497, the parse()
method of Example 16-9, ExponentialFormat
,
doesn't properly handle all possible exponents. Here's a corrected version:
public Number parse(String text, ParsePosition parsePosition) {
int oldIndex = parsePosition.getIndex();
try {
double result = parser.parse(text, parsePosition).doubleValue();
int eposition = text.toUpperCase().indexOf('E');
if (eposition != -1) {
// advance past the E
parsePosition.setIndex(eposition + 1);
// ignore a + sign
if (text.charAt(parsePosition.getIndex()) == '+') {
parsePosition.setIndex(parsePosition.getIndex() + 1);
}
int exponent = parser.parse(text, parsePosition).intValue();
result *= Math.pow(10, exponent);
}
return new Double(result);
}
catch (Exception e) {
parsePosition.setIndex(oldIndex);
return null;
}
}