Example usage for android.text TextUtils isDigitsOnly

List of usage examples for android.text TextUtils isDigitsOnly

Introduction

In this page you can find the example usage for android.text TextUtils isDigitsOnly.

Prototype

public static boolean isDigitsOnly(CharSequence str) 

Source Link

Document

Returns whether the given CharSequence contains only digits.

Usage

From source file:Main.java

public static int str2Int(String str) {
    if (TextUtils.isEmpty(str) || !TextUtils.isDigitsOnly(str)) {
        return 0;
    }//from   w  w w  .java  2 s . co m
    return Integer.parseInt(str);
}

From source file:Main.java

public static boolean isAvailableVc(String vc) {
    if (!TextUtils.isEmpty(vc) && TextUtils.isDigitsOnly(vc) && vc.length() == 6) {
        return true;
    } else {/*from w ww  .  ja  v  a  2 s  . c  om*/
        return false;
    }
}

From source file:Main.java

public static boolean validateInputNumber(String text) {
    boolean digitsOnly = TextUtils.isDigitsOnly(text);
    if (TextUtils.isEmpty(text) || !digitsOnly) {
        return false;
    }//from   ww  w. j av a 2 s  .  c o  m
    return true;
}

From source file:Main.java

public static boolean isPhoneNumberValid(String mobile) {
    return !(TextUtils.isEmpty(mobile) || !TextUtils.isDigitsOnly(mobile) || mobile.length() != 11);
}

From source file:Main.java

public static boolean isIP(String input) {

    if (input.contains(".") && input.length() > 1) {
        return TextUtils.isDigitsOnly(input.replace(".", "").trim());
    } else {/*  w w w  . j a  v a  2 s  . c  o m*/
        return false;
    }
}

From source file:Main.java

public static boolean isMobileValid(String mobile) {
    if (TextUtils.isEmpty(mobile) || !TextUtils.isDigitsOnly(mobile)) {
        return false;
    }/*from  w w  w.  ja  va 2s  .co m*/

    return Pattern.matches("^(\\+86)?(1[3-9][0-9])\\d{8}$", mobile);
}

From source file:Main.java

public static int getTextToInteger(String text) {
    if (TextUtils.isEmpty(text)) {
        return 0;
    } else if (TextUtils.isDigitsOnly(text)) {
        return Integer.valueOf(text);
    }/*from   w ww  .j  ava  2 s  .  c o  m*/
    return 0;
}

From source file:Main.java

public static boolean isOTPOK(String otp_code) {
    if (TextUtils.isEmpty(otp_code)) {
        return false;
    }/*from   www  .  j  av a 2  s.c o m*/

    return TextUtils.isDigitsOnly(otp_code) && (otp_code.length() == 4);
}

From source file:Main.java

public static String clearMonthDate(String word) {
    String result = "";
    for (int i = 0; i < word.length(); i++) {
        if (TextUtils.isDigitsOnly(Character.toString(word.charAt(i)))) {
            result += Character.toString(word.charAt(i));
        }//from ww  w.  j a  va2  s  .c o m
    }
    return result;
}

From source file:Main.java

public static boolean isValidId(String id) {
    try {//w ww.  ja v a  2 s  .  c  o m
        return !TextUtils.isEmpty(id) && TextUtils.isDigitsOnly(id) && Integer.parseInt(id) > 0;
    } catch (Exception e) {
        return false;
    }
}