is String Valid Integer with regular expression - Android java.util.regex

Android examples for java.util.regex:Number Pattern

Description

is String Valid Integer with regular expression

Demo Code

import android.annotation.SuppressLint;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Hashtable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static boolean isValidInteger(String str) {
        if (null == str) {
            return false;
        }/* w ww . ja  va  2  s .  c  o m*/
        Pattern p = Pattern.compile("^\\d*$");
        Matcher match = p.matcher(str);
        return match.matches();
    }

}

Related Tutorials