Java Utililty Methods Number Parse

List of utility methods to do Number Parse

Description

The list of methods to do Number Parse are organized into topic(s).

Method

booleanisNumber(final String str)
Checks whether the provided string is a number.
if (isNullOrEmpty(str)) 
    return false;
final NumberFormat formatter = NumberFormat.getInstance();
final ParsePosition pos = new ParsePosition(0);
formatter.parse(str, pos);
return str.length() == pos.getIndex();
booleanisNumber(String str)
This method is used to check if the String passed is a number/integer only.
NumberFormat formatter = NumberFormat.getInstance();
ParsePosition pos = new ParsePosition(0);
formatter.parse(str, pos);
return str.length() == pos.getIndex();
booleanisNumeric(Class cls)
is Numeric
if (cls != null) {
    return cls == int.class || cls == long.class || cls == float.class || cls == double.class
            || Number.class.isAssignableFrom(cls);
return false;
booleanisNumeric(final String str)
is Numeric
final NumberFormat formatter = NumberFormat.getInstance();
final ParsePosition pos = new ParsePosition(0);
formatter.parse(str, pos);
return str.length() == pos.getIndex();
booleanisNumeric(String str)
Works out of a string could be parsed a Number
boolean isnumeric = false;
try {
    NumberFormat formatter = NumberFormat.getInstance();
    ParsePosition pos = new ParsePosition(0);
    formatter.parse(str, pos);
    isnumeric = (str.length() == pos.getIndex() ? true : false);
} catch (Exception e) {
    isnumeric = false;
...
booleanisNumeric(String str)
Returns true if the given string represents a parseable numeric value, either integer or floating point.
NumberFormat fmt = NumberFormat.getInstance();
ParsePosition pos = new ParsePosition(0);
fmt.parse(str, pos);
return str.length() == pos.getIndex();
booleanisNumeric(String str)
is Numeric
try {
    NUMFORMATTER.get().parse(str);
} catch (Exception e) {
    return false;
return true;
booleanisNumeric(String value, Locale locale)
Test, if a string contains a parsable number.
if (value == null)
    return false;
int start = 0;
final DecimalFormatSymbols symbols = (locale != null) ? DecimalFormatSymbols.getInstance(locale)
        : DecimalFormatSymbols.getInstance();
if (value.startsWith("+") || value.startsWith("-"))
    start++;
boolean fraction = false;
...
booleanisParsable(Object parser, String str)
is Parsable
Class theClass = (parser instanceof Class ? (Class) parser : parser.getClass());
boolean staticOnly = (parser == theClass), foundAtLeastOne = false;
Method[] methods = theClass.getMethods();
for (int index = 0; index < methods.length; index++) {
    Method method = methods[index];
    if (method.getName().startsWith("parse") && (!staticOnly || Modifier.isStatic(method.getModifiers()))
            && Modifier.isPublic(method.getModifiers()) && method.getGenericParameterTypes().length == 1
            && method.getGenericParameterTypes()[0] == String.class) {
...
inttoNumber(char letter)
to Number
switch (letter) {
case ' ':
    return 0;
case 'a':
    return 1;
case 'b':
    return 2;
case 'c':
...