Android String to Number Convert isStringNumberLessThan(String number, int compareInt)

Here you can find the source of isStringNumberLessThan(String number, int compareInt)

Description

is String Number Less Than

Declaration

public static boolean isStringNumberLessThan(String number,
            int compareInt) throws NumberFormatException 

Method Source Code

//package com.java2s;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static boolean isStringNumberLessThan(String number,
            int compareInt) throws NumberFormatException { //no need for this but....
        if (isStringNumber(number)) {
            int numberAsInt = Integer.valueOf(number);
            return numberAsInt < compareInt;
        } else//from   www . j  av  a2  s .c om
            return false;
    }

    public static boolean isStringNumber(String number) {

        if ((number == null)) {
            return false;
        } else {
            String validator = "\\d+";

            Pattern pattern = Pattern.compile(validator);

            Matcher m = pattern.matcher(number);

            return m.matches();
        }
    }
}

Related

  1. isNumeric(String str)
  2. containsNonNumericCharacters(String rawInput)
  3. isNumber(String str)
  4. isNumberLetter(String str)
  5. isStringNumber(String number)