ParsingUtils { public static long parse( final String val, final TimeUnit unit) throws ParseException { long time = convertToTime(val); return unit.convert(time, TimeUnit.MICROSECONDS); }  static boolean convertToBoolean(final String str, final boolean defaultValueIsTrue); static boolean convertToBoolean(final String val); static int convertToInt(final String val); static int convertToInt(final String val, final int defaultValue); static long convertToLong(final String val); static long convertToLong(final String val, final int defaultValue); static long convertToLong(final String val, final long defaultValue); static double convertToDouble(final String val); static double convertToDouble(final String val, final double defaultValue); static long convertToCapacity(
      final String str,
      final long defaultValue); static long convertToTime(final String val); static long parse(
      final String val,
      final TimeUnit unit); static final List<ScaleUnit> INTERVALS; }
@Test public void testParse() throws ParseException { final Object[][] testParameters = new Object[][] {{"1ms", TimeUnit.NANOSECONDS, 1000000L}, {"1ms", TimeUnit.MICROSECONDS, 1000L}, {"1ms", TimeUnit.MILLISECONDS, 1L}, {"1ms", TimeUnit.SECONDS, 0L}, {"1ms", TimeUnit.MINUTES, 0L}, {"1ms", TimeUnit.HOURS, 0L}, {"1ms", TimeUnit.DAYS, 0L}, {"1s", TimeUnit.NANOSECONDS, 1000000000L}, {"1s", TimeUnit.MICROSECONDS, 1000000L}, {"1s", TimeUnit.MILLISECONDS, 1000L}, {"1s", TimeUnit.SECONDS, 1L}, {"1s", TimeUnit.MINUTES, 0L}, {"1s", TimeUnit.HOURS, 0L}, {"1s", TimeUnit.DAYS, 0L}, {"1m", TimeUnit.NANOSECONDS, 60000000000L}, {"1m", TimeUnit.MICROSECONDS, 60000000L}, {"1m", TimeUnit.MILLISECONDS, 60000L}, {"1m", TimeUnit.SECONDS, 60L}, {"1m", TimeUnit.MINUTES, 1L}, {"1m", TimeUnit.HOURS, 0L}, {"1m", TimeUnit.DAYS, 0L}}; for (final Object[] testParameter : testParameters) { long expected = (Long) testParameter[2]; String val = (String) testParameter[0]; TimeUnit unit = (TimeUnit) testParameter[1]; assertEquals(expected, ParsingUtils.parse(val, unit)); } }