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;
//License from project: Open Source License 

public class Main {
    public static int toInt(Object obj) {
        String str = obj != null ? obj.toString().trim() : "";
        return "".equals(str) ? 0 : Integer.parseInt(str);
    }/*from  www  .  ja  v a  2s  .  c  o m*/

    public static int toInt(Object obj, int intStr) {
        String str = obj != null ? obj.toString().trim() : "";
        return "".equals(str) ? intStr : Integer.parseInt(str);
    }

    public static String toString(Object obj) {
        return obj != null ? obj.toString() : "";
    }

    public static String toString(Object obj, String str) {
        return obj != null ? obj.toString() : str;
    }
}

Related

  1. toInt(Object num, int defValue)
  2. toInt(Object o)
  3. toInt(Object o, int defaultValue)
  4. toInt(Object obj)
  5. toInt(Object obj)
  6. toInt(Object obj)
  7. toInt(Object obj)
  8. toInt(Object obj)
  9. toInt(Object obj)