NumberUtils { public static long parseLong(String val, long defaultValue) { long ret = defaultValue; try { ret = Long.parseLong(val); } catch (Exception ignored) { } return ret; }  static long parseLong(String val, long defaultValue); static long parseLong(byte[] val, long defaultValue); static boolean longEquals(Long va, Long vb);  }
@Test public void test_parseLong_bytes() { String str = "12345"; long result = NumberUtils.parseLong(str.getBytes(), 0L); Assertions.assertEquals(12345L, result); }
@Test public void test_parseLong_bytes_null() { byte[] in = null; long result = NumberUtils.parseLong(in, 123L); Assertions.assertEquals(123L, result); }
@Test public void test_parseLong_not_number() { String str = "123ab"; long result = NumberUtils.parseLong(str, 123L); Assertions.assertEquals(123L, result); }