MathUtil { public static long parseLong(String longStr, long defaultValue){ try { return Long.parseLong(longStr); } catch (NumberFormatException e) { return defaultValue; } }  static int parseInt(String intStr, int defaultValue); static long parseLong(String longStr, long defaultValue); static int getNonNegative(int originValue); static int getNonNegativeRange24bit(int originValue);  }
@Test public void parseLong() { assertTrue(MathUtil.parseLong("-1",0)==-1); assertTrue(MathUtil.parseLong("0",-1)==0); assertTrue(MathUtil.parseLong("1",0)==1); assertTrue(MathUtil.parseLong("",0)==0); assertTrue(MathUtil.parseLong(null,0)==0); assertTrue(MathUtil.parseLong("Invalid Int String",0)==0); }