Here you can find the source of convertStringToInt(final String strNumber)
Parameter | Description |
---|---|
strNumber | - the String to convert |
public static int convertStringToInt(final String strNumber)
//package com.java2s; /**/*from w w w.ja v a 2 s .c o m*/ * Generic utility class. * <p/> * This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivs 3.0 United States License. To * view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/3.0/us/ or send a letter to Creative * Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA. * * @author $Author: jal55 $ * @version $Rev: 8005 $ * @package edu.psu.iam.cpr.core.util * @lastrevision $Date: 2013-09-11 08:47:10 -0400 (Wed, 11 Sep 2013) $ */ public class Main { /** * Convert a String to a primitive 'int' * * @param strNumber - the String to convert * @return return an 'int' number representing the string, or 0 if the number is not valid */ public static int convertStringToInt(final String strNumber) { int numericNumber = 0; try { numericNumber = Integer.parseInt(strNumber); } // Null, and Empty Strings yield an 'int' of 0 catch (NumberFormatException nfe) { } return numericNumber; } }