Java String to Int convertStringToInteger(String strParaConvert)

Here you can find the source of convertStringToInteger(String strParaConvert)

Description

Converte uma String em Integer.

License

Open Source License

Parameter

Parameter Description
strParaConvert a parameter

Declaration

public static Integer convertStringToInteger(String strParaConvert) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*  w  w w  .j  a  v a2 s.com*/
     * Converte uma String em Integer.
     * @param strParaConvert
     * @return
     */
    public static Integer convertStringToInteger(String strParaConvert) {
        if (strParaConvert == null)
            return new Integer(0);
        if (strParaConvert.trim().equalsIgnoreCase(""))
            return new Integer(0);

        try {
            int aux = Integer.parseInt(strParaConvert);
            return new Integer(aux);
        } catch (Exception e) {
            return new Integer(0);
        }
    }
}

Related

  1. convertStringToInt(String value)
  2. convertStringToInteger(String num)
  3. convertStringToInteger(String s)
  4. convertStringToInteger(String s)
  5. convertStringToInteger(String string)
  6. convertStringToInteger(String value)
  7. convertStringToInteger(String value)
  8. convertStringToInteger(String value)