Java Utililty Methods String to Int

List of utility methods to do String to Int

Description

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

Method

intasInt(String number)
as Int
if (number.charAt(0) == '+') 
    number = number.substring(1);
return Integer.parseInt(number);
intasInt(String str)
as Int
try {
    return Integer.valueOf(str);
} catch (NumberFormatException nfex) {
    return Integer.MIN_VALUE;
intasInt(String str)
as Int
if (str != null && str.length() > 0)
    try {
        return Integer.parseInt(str.trim());
    } catch (Exception e) {
return 0;
intasInt(String str, int defaultValue)
as Int
try {
    return Integer.parseInt(str);
} catch (Exception e) {
    return defaultValue;
intasInt(String sval, int dflt)
Convert string to integer.
return (null == sval) ? dflt : Integer.parseInt(sval);
IntegerasInt(String value)
Returns the integer corresponding to the given string value .
return asInt(value, null);
IntegerasInteger(String param)
as Integer
if (param == null) {
    return null;
if (param instanceof String) {
    return Integer.valueOf(param);
} else {
    throw new IllegalArgumentException("Invalid agrument type. Convertion can be made only from String.");
IntegerasInteger(String string)
Converts string to integer
return (string == null) ? null : Integer.valueOf(string);
IntegerasInteger(String v)
as Integer
try {
    return (v != null) ? Integer.valueOf(v) : null;
} catch (NumberFormatException ex) {
    return null;
intasInteger(String value)
Converts a String value into a int.
return Integer.parseInt(value);