Here you can find the source of null2Int(Object object, int def)
public static int null2Int(Object object, int def)
//package com.java2s; //License from project: Apache License public class Main { public static int null2Int(Object s) { return null2Int(s, -1); }// w w w . j a v a2 s . c o m public static int null2Int(Object object, int def) { if (object != null) { try { return Integer.parseInt(object.toString()); } catch (Exception e) { } } return def; } }