is String all Digit by regex - Android java.util.regex

Android examples for java.util.regex:Digit Pattern

Description

is String all Digit by regex

Demo Code

import android.text.TextUtils;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{

    public static boolean isDigit(String strNum) {
        Pattern pattern = Pattern.compile("[0-9]{1,}");
        Matcher matcher = pattern.matcher((CharSequence) strNum);
        return matcher.matches();
    }/*from   ww  w .  j av a 2  s . com*/

}

Related Tutorials