account for unavailability of NumberFormat.getIntegerInstance(...) pre JDK 1.4

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@600608 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Matthew Jason Benson 2007-12-03 17:23:05 +00:00
parent 426bd462c9
commit 20817861c9
1 changed files with 12 additions and 2 deletions

View File

@ -29,6 +29,8 @@ import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Locale;
import org.apache.commons.lang.SystemUtils;
import junit.framework.TestCase;
/**
@ -160,12 +162,12 @@ public abstract class AbstractMessageFormatTest extends TestCase {
}
public void testInteger() {
doAssertions(NumberFormat.getIntegerInstance(locale), NUMBERS,
doAssertions(getIntegerNumberFormat(locale), NUMBERS,
"number,integer");
}
public void testIntegerLooseFormatting() {
doAssertions(NumberFormat.getIntegerInstance(locale), NUMBERS,
doAssertions(getIntegerNumberFormat(locale), NUMBERS,
" number , integer ", "number,integer");
}
@ -291,4 +293,12 @@ public abstract class AbstractMessageFormatTest extends TestCase {
doAssertions(new ChoiceFormat(choice.toString()), NUMBERS, format
.toString());
}
private NumberFormat getIntegerNumberFormat(Locale locale) {
NumberFormat result = NumberFormat.getInstance(locale);
result.setMaximumFractionDigits(0);
result.setParseIntegerOnly(true);
return result;
}
}