Here you can find the source of toInteger(Object ob, Integer defaultInteger)
public static Integer toInteger(Object ob, Integer defaultInteger)
//package com.java2s; public class Main { public static Integer toInteger(Object ob, Integer defaultInteger) { if (ob == null) { return defaultInteger; }/*from w ww .jav a 2 s . c o m*/ if (ob instanceof Integer) { return ((Integer) ob).intValue(); } else if (ob instanceof Float) { return ((Float) ob).intValue(); } else if (ob instanceof Double) { return ((Double) ob).intValue(); } else if (ob instanceof Byte) { return ((Byte) ob).intValue(); } else { try { return new Integer(ob.toString()); } catch (Exception e) { return defaultInteger; } } } public static Integer toInteger(Object ob) { return toInteger(ob, 0); } }