EnvUtil { public static long getLong(String envName, long defaultValue) { long value = defaultValue; String envValue = System.getenv(envName); if (envValue != null) { try { value = Long.parseLong(envValue); } catch (NumberFormatException e) { } } return value; }  static int getInt(String envName, int defaultValue); static long getLong(String envName, long defaultValue);  }
@Test public void getLong() { assertEquals(12345678901234567L, EnvUtil.getLong("myLong", 123L)); assertEquals(987654321987654321L, EnvUtil.getLong("wrongLong", 987654321987654321L)); }