Parse the string to integer, does not throw exception, return null. - Android java.lang

Android examples for java.lang:Math

Description

Parse the string to integer, does not throw exception, return null.

Demo Code


//package com.java2s;

public class Main {
    /**/*from  www. jav  a2s  .c o  m*/
     * Parse the string to integer, does not throw exception, return null.
     * <br>
     * 
     * @param value -{@link String}
     * @return
     */
    public static Integer parseInteger(String value) {
        Integer parseValue = null;
        try {
            parseValue = Integer.parseInt(value);
        } catch (Exception e) {
            //ignored
            parseValue = null;
        }
        return parseValue;
    }
}

Related Tutorials