Java Regex Int Validate parseInteger(String str)

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

Description

parse Integer

License

Apache License

Declaration

public static int parseInteger(String str) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.regex.Pattern;

public class Main {
    private static final Pattern INT_PATTERN = Pattern.compile("^\\d+$");

    public static int parseInteger(String str) {
        return !isInteger(str) ? 0 : Integer.parseInt(str);
    }//from   www.  j a  va 2 s .  c o  m

    public static boolean isInteger(String str) {
        return str != null && str.length() != 0 ? INT_PATTERN.matcher(str)
                .matches() : false;
    }
}

Related

  1. parseInt(String value)
  2. parseInt(String[] strs)
  3. parseInteger(String attrVal)
  4. parseInteger(String inStr, Integer def)
  5. parseInteger(String key, String sourceString)
  6. parseIntegerList(String var0, int var1, int var2)
  7. parseIntegers(String integerString)
  8. parseIntToString(String value)