Android String Parse isAllDigital(String str)

Here you can find the source of isAllDigital(String str)

Description

is All Digital

Declaration

public static boolean isAllDigital(String str) 

Method Source Code

//package com.java2s;

public class Main {

    public static boolean isAllDigital(String str) {
        boolean is = true;
        if (getCharNum(str, '.') >= 2) {
            return false;
        }/*from   www  .j  a v a  2s.  c o  m*/
        for (int i = 0; i < str.length(); ++i) {
            if ((str.charAt(i) - '0' < 0 || str.charAt(i) - '9' > 0)
                    && str.charAt(i) - '.' != 0) {
                is = false;
                break;
            }
        }
        return is;
    }

    public static int getCharNum(String str, char ch) {
        int num = 0;
        for (int i = 0; i < str.length(); ++i) {
            if (str.charAt(i) - ch == 0) {
                num++;
            }
        }
        return num;
    }
}

Related

  1. isASCII(String str)
  2. isDecimal(String str)
  3. isDifferent(String str1, String str2)
  4. isDigits(Object o)
  5. isDigits(String s)