is String a Valid Integer - Android java.lang

Android examples for java.lang:String Parse

Description

is String a Valid Integer

Demo Code


//package com.java2s;
import android.text.TextUtils;

public class Main {
    public static boolean isValidInteger(String value) {
        if (TextUtils.isEmpty(value)) {
            return false;
        }/*from   w  w  w  .  j  a va2s.  c  om*/

        try {
            Integer.parseInt(value);
        } catch (NumberFormatException e) {
            return false;
        }

        return true;
    }
}

Related Tutorials