Java Regex Int Validate parseInt(Object str)

Here you can find the source of parseInt(Object str)

Description

parse Int

License

Apache License

Declaration

public static Integer parseInt(Object str) 

Method Source Code

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

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

public class Main {
    public static Integer parseInt(Object str) {
        return str == null ? 0
                : Integer.valueOf((isNumeric(str.toString())) ? Integer.parseInt(str.toString()) : 0);
    }//ww w  . j av  a 2 s.  c  o m

    public static boolean isNumeric(String str) {
        Matcher isNum = Pattern.compile("(-|\\+)?[0-9]+(.[0-9]+\\+)?").matcher(str);
        return isNum.matches();
    }
}

Related

  1. parseInt(String value)
  2. parseInt(String[] strs)
  3. parseInteger(String attrVal)
  4. parseInteger(String inStr, Integer def)