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

intparseInt(String s)
parse Int
try {
    return Integer.parseInt(s);
} catch (NumberFormatException e) {
    return 0;
booleanisInt(final String chaineToTest)
is Int
try {
    Integer.parseInt(chaineToTest);
    return true;
} catch (final Exception e) {
    return false;
booleanisInteger(String string)
is Integer
try {
    Integer.parseInt(string);
} catch (NumberFormatException e) {
    return false;
return true;
intgetValueOfSafely(String stringToConvert, int defaultValue)
Converts stringToConvert to int safely
if (null == stringToConvert) {
    return defaultValue;
int convertedValue = 0;
try {
    convertedValue = Integer.valueOf(stringToConvert);
} catch (NumberFormatException ex) {
    return defaultValue;
...
inttoInt(String str, int defValue)
to Int
try {
    return Integer.parseInt(str.replace("+", ""));
} catch (Exception e) {
    e.printStackTrace();
return defValue;
inttoInt(Object obj)
to Int
if (obj == null)
    return 0;
return toInt(obj.toString(), 0);
booleanisNullOrWhiteSpace(final String string)
is Null Or White Space
return string == null || string.length() == 0
        || string.trim().length() == 0;
booleanisNum(String s)
is Num
try {
    Integer.parseInt(s);
} catch (NumberFormatException nfe) {
    return false;
return true;
booleanisNumber(String str)
is Number
try {
    Integer.parseInt(str);
    return true;
} catch (Exception e) {
    return false;
booleanisNumber(String str)
is Number
try {
    Integer.valueOf(str);
} catch (Exception e) {
    return false;
return true;