class TimeParser {

    public long parse() {
        if (time == null) {
            return 0;
        }
        final boolean isSeconds;
        if (time.endsWith("ms")) {
            isSeconds = false;
        } else if (time.endsWith("s")) {
            isSeconds = true;
        } else {
            return -1;
        }
        final String timeValue;
        final long factor;
        if (isSeconds) {
            timeValue = time.substring(0, time.length() - 1);
            factor = MSECS_PER_SEC;
        } else {
            timeValue = time.substring(0, time.length() - "ms".length());
            factor = 1;
        }
        final BigDecimal number;
        try {
            number = new BigDecimal(timeValue);
        } catch (NumberFormatException e) {
            return -1;
        }
        float flt = number.floatValue();
        return (long) (flt * factor);
    }

    public  TimeParser(final String str);

}