@Test public void testIsNumber() throws Exception { Assert.assertTrue(NumberUtils.isNumber("0")); Assert.assertTrue(NumberUtils.isNumber("123")); Assert.assertTrue(NumberUtils.isNumber("-123")); Assert.assertTrue(NumberUtils.isNumber(String.valueOf(Long.MAX_VALUE))); Assert.assertTrue(NumberUtils.isNumber(String.valueOf(Long.MIN_VALUE))); Assert.assertTrue(NumberUtils.isNumber(String.valueOf(Double.MAX_VALUE))); Assert.assertTrue(NumberUtils.isNumber(String.valueOf(Double.MAX_EXPONENT))); Assert.assertTrue(NumberUtils.isNumber(String.valueOf(Double.MIN_VALUE))); Assert.assertTrue(NumberUtils.isNumber(String.valueOf(Double.MIN_NORMAL))); Assert.assertTrue(NumberUtils.isNumber(String.valueOf(Double.MIN_EXPONENT))); Assert.assertFalse(NumberUtils.isNumber(String.valueOf("3.40282346638528860f+38f"))); Assert.assertFalse(NumberUtils.isNumber(String.valueOf("1.40129846432481707f-45f"))); Assert.assertFalse(NumberUtils.isNumber(String.valueOf("-"))); Assert.assertFalse(NumberUtils.isNumber(String.valueOf("a"))); }
public static boolean isNumber(String number) { return tryParseInt(number, null) != null || tryParseLong(number, null) != null || tryParseFloat(number, null) != null || tryParseDouble(number, null) != null; }
NumberUtils { public static boolean isNumber(String number) { return tryParseInt(number, null) != null || tryParseLong(number, null) != null || tryParseFloat(number, null) != null || tryParseDouble(number, null) != null; } }
NumberUtils { public static boolean isNumber(String number) { return tryParseInt(number, null) != null || tryParseLong(number, null) != null || tryParseFloat(number, null) != null || tryParseDouble(number, null) != null; } private  NumberUtils(); }
NumberUtils { public static boolean isNumber(String number) { return tryParseInt(number, null) != null || tryParseLong(number, null) != null || tryParseFloat(number, null) != null || tryParseDouble(number, null) != null; } private  NumberUtils(); static Long tryParseLong(String number); static Long tryParseLong(String number, Long fallback); static Integer tryParseInt(String number); static Integer tryParseInt(String number, Integer fallback); static Float tryParseFloat(String number); static Float tryParseFloat(String number, Float fallback); static Double tryParseDouble(String number); static Double tryParseDouble(String number, Double fallback); static boolean isNumber(String number); }
NumberUtils { public static boolean isNumber(String number) { return tryParseInt(number, null) != null || tryParseLong(number, null) != null || tryParseFloat(number, null) != null || tryParseDouble(number, null) != null; } private  NumberUtils(); static Long tryParseLong(String number); static Long tryParseLong(String number, Long fallback); static Integer tryParseInt(String number); static Integer tryParseInt(String number, Integer fallback); static Float tryParseFloat(String number); static Float tryParseFloat(String number, Float fallback); static Double tryParseDouble(String number); static Double tryParseDouble(String number, Double fallback); static boolean isNumber(String number); static final String TAG; }