Convert Object to integer - Android java.lang

Android examples for java.lang:Integer

Description

Convert Object to integer

Demo Code

import android.content.Context;
import java.text.DecimalFormat;

public class Main{

    public static boolean num(Object o) {
        int n = 0;
        try {//from  ww  w. ja v  a  2s. c om
            n = Integer.parseInt(o.toString().trim());
        } catch (NumberFormatException e) {
            e.printStackTrace();
        }
        if (n > 0) {
            return true;
        } else {
            return false;
        }
    }

}

Related Tutorials