Android String to Int Convert toInt(Object obj)

Here you can find the source of toInt(Object obj)

Description

to Int

Declaration

public static int toInt(Object obj) 

Method Source Code

//package com.java2s;

public class Main {

    public static int toInt(String str, int defValue) {
        try {/*from   ww  w .  j  a v  a 2s.  com*/
            return Integer.parseInt(str.replace("+", ""));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return defValue;
    }

    public static int toInt(Object obj) {
        if (obj == null)
            return 0;
        return toInt(obj.toString(), 0);
    }
}

Related

  1. parseInt(String s)
  2. isInt(final String chaineToTest)
  3. isInteger(String string)
  4. getValueOfSafely(String stringToConvert, int defaultValue)
  5. toInt(String str, int defValue)
  6. isNullOrWhiteSpace(final String string)
  7. isNum(String s)
  8. isNumber(String str)
  9. isNumber(String str)