Android Utililty Methods String to Number Convert

List of utility methods to do String to Number Convert

Description

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

Method

booleanisNumeric(String str)
is Numeric
final String number = "0123456789";
for (int i = 0; i < str.length(); i++) {
    if (number.indexOf(str.charAt(i)) == -1) {
        return false;
return true;
booleanisNumeric(String str)
is Numeric
Pattern pattern = Pattern.compile("^[-\\+]?[\\d]*$");
return pattern.matcher(str).matches();
booleanisNumeric(String str)
is Numeric
int index = str.indexOf(".");
if (index == -1) {
    return isIntegral(str);
if ((index == 0) || (index == str.length() - 1)) {
    return false;
String num1 = str.substring(0, index);
...
booleanisNumeric(String str)
is Numeric
Pattern pattern = Pattern.compile("[0-9]*");
Matcher isNum = pattern.matcher(str);
if (!isNum.matches()) {
    return false;
return true;
booleanisNumeric(String string)
Tests if a string is numeric, i.e.
if (string == null || string.length() == 0)
    return false;
int l = string.length();
for (int i = 0; i < l; i++) {
    if (!Character.isDigit(string.codePointAt(i)))
        return false;
return true;
...
booleanisLetterNumeric(String s)
Return true if the string is alphanum.
int i = 0, len = s.length();
while (i < len
        && (Character.isLowerCase(s.charAt(i))
                || Character.isUpperCase(s.charAt(i)) || Character
                    .isDigit(s.charAt(i)))) {
    i++;
return (i >= len);
...
booleanisNumericOnly(String pString)
is Numeric Only
return Pattern.matches("[0-9[-\\s]]+", pString);
booleanisNumeric(String str)
is Numeric
if (str == null || str.length() == 0) {
    return false;
Pattern pattern = Pattern.compile("[0-9]*");
return pattern.matcher(str).matches();
booleancontainsNonNumericCharacters(String rawInput)
contains Non Numeric Characters
Pattern p = Pattern.compile("(\\D+)");
Matcher m = p.matcher(rawInput);
return m.find();
BooleanisNumber(String str)
is Number
Boolean isNumber = false;
String expr = "^[0-9]+$";
if (str.matches(expr)) {
    isNumber = true;
return isNumber;