Here you can find the source of toInteger(Object value)
public static Integer toInteger(Object value)
//package com.java2s; /*//from w w w.j a v a 2s . co m * This file is part of the Jose Project * see http://jose-chess.sourceforge.net/ * (c) 2002-2006 Peter Sch?fer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * */ public class Main { public static Integer toInteger(Object value) { if (value == null) return null; // easy if (value instanceof Integer) return (Integer) value; if (value instanceof Number) return new Integer(((Number) value).intValue()); String svalue = toString(value); if (svalue == null) return null; else return new Integer(svalue); } public static String toString(Object value) { if (value == null) return null; // easy String svalue = value.toString(); if (svalue == null) return null; svalue = svalue.trim(); if (svalue.length() == 0) return null; return svalue; } }