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

IntegerasInteger(String value)
Returns the given value String as Integer.
return asInteger(value, null);
intconvertStringToInt(final String str)
Convert the specified string into an integer.
int val = -1;
try {
    val = Integer.parseInt(str);
} catch (NumberFormatException nfe) {
    val = -1;
return val;
intconvertStringToInt(final String strNumber)
Convert a String to a primitive 'int'
int numericNumber = 0;
try {
    numericNumber = Integer.parseInt(strNumber);
catch (NumberFormatException nfe) {
return numericNumber;
IntegerconvertStringToInt(String number)

Return the Integer value of the input string.

if (number == null) {
    return null;
try {
    return Integer.parseInt(number);
} catch (NumberFormatException e) {
    return null;
intconvertStringToInt(String str)
convert String To Int
int val = 0;
try {
    val = Integer.parseInt(str);
} catch (Exception e) {
    e.getMessage();
return val;
intconvertStringToInt(String value)
Converts the string value to int.
if (value == null) {
    return -1;
return Integer.parseInt(value);
intconvertStringToInteger(String num)
convert String To Integer
int val = 0;
if (num != null) {
    val = Integer.parseInt(num);
return val;
IntegerconvertStringToInteger(String s)
Converts a string to Integer.
Integer _integer = null;
if (s != null) {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < s.length(); i++) {
        if (Character.isDigit(s.charAt(i))) {
            sb.append(s.charAt(i));
    if (sb.length() > 0) {
        int id = Integer.parseInt(sb.toString());
        _integer = new Integer(id);
return _integer;
IntegerconvertStringToInteger(String s)
convert String To Integer
return Integer.valueOf(s);
IntegerconvertStringToInteger(String string)
convert String To Integer
if (string == null) {
    return null;
try {
    Integer integer = Integer.parseInt(string.trim());
    return integer;
} catch (NumberFormatException e) {
    return null;
...