Here you can find the source of toInteger(Object value)
public static Integer toInteger(Object value)
//package com.java2s; //License from project: Apache License public class Main { /**/* w w w. j a v a 2 s. c o m*/ * Convert an Object to an Integer. */ public static Integer toInteger(Object value) { if (value == null) return null; if (value instanceof Integer) return (Integer) value; if (value instanceof String) { if ("".equals((String) value)) return null; return new Integer((String) value); } if (value instanceof Number) return new Integer(((Number) value).intValue()); return new Integer(value.toString()); } /** * Convert an Object to an int, or 0 if it is null. */ public static int intValue(Object value) { if (value == null) return 0; return toInteger(value).intValue(); } }