Java Integer Create toInt(Object obj)

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

Description

to Int

License

Open Source License

Declaration

public static int toInt(Object obj) 

Method Source Code

//package com.java2s;

public class Main {
    public static int toInt(Object obj) {
        Integer i = toInteger(obj);

        if (i != null) {
            return i.intValue();
        }//from  w  ww .j  ava  2 s  .  c  o m

        return 0;
    }

    public static Integer toInteger(Object obj) {
        if (obj != null) {
            if (obj instanceof Integer) {
                return (Integer) obj;
            } else {
                try {
                    return Integer.parseInt(String.valueOf(obj));
                } catch (Exception e) {
                }
            }
        }

        return null;
    }
}

Related

  1. toInt(Object obj)
  2. toInt(Object obj)
  3. toInt(Object obj)
  4. toInt(Object obj)
  5. toInt(Object obj)
  6. toInt(Object obj)
  7. toInt(Object object)
  8. toInt(Object object, int defaultValue)
  9. toInt(Object objValue)