Here you can find the source of tryParseInt(Object obj, Integer defaultVal)
public static Integer tryParseInt(Object obj, Integer defaultVal)
//package com.java2s; //License from project: Apache License public class Main { public static Integer tryParseInt(Object obj, Integer defaultVal) { if (obj == null) return defaultVal; if (obj instanceof Integer) return (Integer) obj; try {// w w w . ja va2 s .c om String val = obj.toString(); return Integer.parseInt(val); } catch (Exception e) { return defaultVal; } } }