Android String Parse isDigits(Object o)

Here you can find the source of isDigits(Object o)

Description

is Digits

Declaration

public static final boolean isDigits(Object o) 

Method Source Code

//package com.java2s;

public class Main {

    public static final boolean isDigits(String s) {
        if (s == null || s.length() == 0)
            return false;
        int begin = (s.charAt(0) == '-') ? 1 : 0;
        for (int i = begin; i < s.length(); i++) {
            if (!Character.isDigit(s.charAt(i)))
                return false;
        }//w w w . ja  v  a2 s.com
        return true;
    }

    public static final boolean isDigits(Object o) {
        if (o == null) {
            return false;
        }
        String s = o.toString();
        if (s.length() == 0)
            return false;
        //??????
        int i = (s.charAt(0) == '-') ? 1 : 0;
        for (int j = s.length(); i < j; i++) {
            if (!Character.isDigit(s.charAt(i)))
                return false;
        }
        return true;
    }
}

Related

  1. isASCII(String str)
  2. isAllDigital(String str)
  3. isDecimal(String str)
  4. isDifferent(String str1, String str2)
  5. isDigits(String s)
  6. isDouble(String str)
  7. isIDCard(String str)
  8. isInteger(String input)