NumberUtils { public static Number parseNumber(String value) throws NumberFormatException { return parseNumber(value, false); }  static boolean isNumeric(String value, Locale locale); static Number parseNumber(String value); static Number parseNumber(String value, Locale... locales); static Number parseNumber(String value, boolean integerOnly, Locale... locales); static String printNumber(Number value, int integerDigits, int fractionDigits); static String printNumber(Number value, int integerDigits, int fractionDigits, Locale locale);  }
@Test public void testParseNumber() { NumberFormat format = NumberFormat.getNumberInstance(Locale.ENGLISH); format.setGroupingUsed(false); format.setMinimumFractionDigits(0); Assert.assertEquals("1400", format.format(NumberUtils.parseNumber("1400", false))); Assert.assertEquals("1400", format.format(NumberUtils.parseNumber("1400", true))); Assert.assertEquals("1400", format.format(NumberUtils.parseNumber("1.400", true, Locale.GERMAN))); Assert.assertEquals("1400", format.format(NumberUtils.parseNumber("1.400", false, Locale.GERMAN))); Assert.assertEquals("1.4", format.format(NumberUtils.parseNumber("1,400", false, Locale.GERMAN))); Assert.assertEquals("1400.15", format.format(NumberUtils.parseNumber("1.400,15", false, Locale.GERMAN))); Assert.assertEquals("1.4", format.format(NumberUtils.parseNumber("1.400", false, Locale.ENGLISH))); Assert.assertEquals("1400", format.format(NumberUtils.parseNumber("1,400", true, Locale.ENGLISH))); Assert.assertEquals("1400", format.format(NumberUtils.parseNumber("1,400", false, Locale.ENGLISH))); Assert.assertEquals("1400.15", format.format(NumberUtils.parseNumber("1,400.15", false, Locale.ENGLISH))); }