class ParsingUtils {

  public static long convertToTime(final String val) throws ParseException {
    if (null == val) {
      return 0;
    }

    final String lowerVal = val.toLowerCase();
    for (final ScaleUnit unit : INTERVALS) {
      final String units = unit.units;
      if (lowerVal.endsWith(units)) {
        final String digits = lowerVal.substring(0, lowerVal.length() - units.length()).trim();
        final Double microSeconds = Double.parseDouble(digits) * unit.scale;
        return microSeconds.longValue();
      }
    }

    throw new ParseException(val, 0);
  }

}