Java Integer Create toInt(String param)

Here you can find the source of toInt(String param)

Description

Converts param to an int

License

Open Source License

Parameter

Parameter Description

Return

intconverted param

Declaration

public static int toInt(String param) 

Method Source Code

//package com.java2s;
/* Copyright (c) Inmobia Mobile Technology, Inc. All Rights Reserved.
 * /* ww w. j  av a2  s  .c om*/
 * This software is the confidential and proprietary information of Inmobia 
 * Mobile Technology. ("Confidential Information").  You shall not disclose such 
 * Confidential Information and shall use it only in accordance with the terms 
 * of the license agreement you entered into with Inmobia Mobile Technology.
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

public class Main {
    /**
     * 
     * 
     * Converts param to an <code>int</code>
     * <p>
     * 
     * @param<code>String</code>param to convert to an <code>int</code>
     * @return<code>int</code>converted param
     */
    public static int toInt(String param) {

        int result = 0;
        if (isParamSet(param))
            result = Integer.valueOf(param);

        return result;

    }

    /**
     * Checks if param is set
     * 
     * @param <code>String</code>param, parameter to check if it has been set
     * @return<code>boolean</code> true if param is set and false otherwise
     */
    public static boolean isParamSet(String param) {

        boolean isSet = false;
        if (param != null && param.trim().length() > 0)
            isSet = true;
        return isSet;

    }
}

Related

  1. toInt(String input, int defaultValue)
  2. toInt(String input, int offset, int length)
  3. toInt(String intValue, int defaultValue)
  4. toInt(String number)
  5. toInt(String numStr, int defaultValue)
  6. toInt(String param)
  7. toInt(String pString)
  8. toInt(String s)
  9. toInt(String s)