Android Utililty Methods String to Int Convert

List of utility methods to do String to Int Convert

Description

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

Method

booleanisNumber(String str)
is Number
if (isLong(str)) {
    return true;
Pattern pattern = Pattern.compile("(-)?(\\d*)\\.{0,1}(\\d*)");
Matcher isNum = pattern.matcher(str);
if (!isNum.matches()) {
    return false;
return true;
booleanisNumber(final String s)
is Number
if (s == null || s.length() == 0) {
    return false;
int size = s.length();
for (int i = 0; i < size; i++) {
    char chr = s.charAt(i);
    if (chr < '0' || '9' < chr) {
        return false;
...
booleanisNumberString(String input)
is Number String
if (!isNullOrEmpty(input)) {
    if (input.matches("[0-9]+")) {
        return true;
return false;
booleanisNumberic(String str)
is Numberic
final Pattern p = Pattern.compile("[0-9]*");
final Matcher m = p.matcher(str);
return m.matches();
inttoInt(Object obj)
to Int
if (obj == null)
    return 0;
return toInt(obj.toString(), 0);
inttoInt(String obj)
to Int
try {
    return Integer.parseInt(obj);
} catch (Exception e) {
return 0;
inttoInt(String str, int defValue)
to Int
try {
    return Integer.parseInt(str);
} catch (Exception e) {
return defValue;
inttoInt(String str, int defValue)
to Int
try {
    return Integer.parseInt(str);
} catch (Exception e) {
return defValue;
inttoInteger(String value)
to Integer
try {
    return Integer.parseInt(value);
} catch (Exception e) {
    Debug.warning(e);
return 0;
inttoNumber(String str)
to Number
str = defaultIfBlank(str, "0");
if (isNumber(str))
    return Integer.valueOf(str);
else
    return 0;