Java tutorial
//package com.java2s; public class Main { /** * Tries to convert the string to an Integer. If there is an error it * returns null * * @param number * @return */ public static Integer convertStringToInteger(String number) { if (number == null || number.isEmpty()) { return null; } try { return Integer.parseInt(number); } catch (NumberFormatException e) { return null; } } }