Java tutorial
//package com.java2s; public class Main { public static int getValueByInt(String value) { int result = 0; if (value != null && !value.equals("")) { try { result = Integer.valueOf(value); } catch (NumberFormatException e) { } } return result; } }