Java String to Int convertStringToInt(String number)

Here you can find the source of convertStringToInt(String number)

Description

Return the Integer value of the input string.

License

Open Source License

Parameter

Parameter Description
number number in String type

Return

the number in Integer type, return null if the number can not be converted to Integer type.

Declaration

public static Integer convertStringToInt(String number) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from  www.jav a 2s.  c  o  m
     * <p>
     * Return the Integer value of the input string.
     * </p>
     *
     * @param number
     *                  number in String type
     * @return
     *                  the number in Integer type, return null
     *                  if the number can not be converted to Integer
     *                  type.
     */
    public static Integer convertStringToInt(String number) {
        if (number == null) {
            return null;
        }
        try {
            return Integer.parseInt(number);
        } catch (NumberFormatException e) {
            return null;
        }
    }
}

Related

  1. asInteger(String v)
  2. asInteger(String value)
  3. asInteger(String value)
  4. convertStringToInt(final String str)
  5. convertStringToInt(final String strNumber)
  6. convertStringToInt(String str)
  7. convertStringToInt(String value)
  8. convertStringToInteger(String num)
  9. convertStringToInteger(String s)