Android Object to Int Convert objToNonNegativeInt(Object obj)

Here you can find the source of objToNonNegativeInt(Object obj)

Description

obj To Non Negative Int

Declaration

public static final int objToNonNegativeInt(Object obj) 

Method Source Code

//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;
    }
}