Here you can find the source of objToNonNegativeInt(Object obj)
public static final int objToNonNegativeInt(Object obj)
//package com.java2s; public class Main { public static final int objToNonNegativeInt(Object obj) { if (obj != null) { String s = obj.toString(); if (s.matches("[0-9]*")) { return Integer.parseInt(s); }//from www. j av a 2 s . co m } return -1; } }