is Numeric string by regular expression - Android java.util.regex

Android examples for java.util.regex:Numeric Pattern

Description

is Numeric string by regular expression

Demo Code

import android.util.Log;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{
    public static boolean isNumeric(String str) {
        Pattern pattern = Pattern.compile("[0-9]*");
        Matcher isNum = pattern.matcher(str);
        if (!isNum.matches()) {
            return false;
        }/*from  w ww. j  a  va2  s  .  c  o  m*/
        return true;
    }

}

Related Tutorials