public static long parseTimeInterval(String str) {
        try {
            int len = str.length();
            char suffix = str.charAt(len - 1);
            String numstr;
            long mult = 1;
            if (Character.isDigit(suffix)) {
                numstr = str;
            } else {
                numstr = str.substring(0, len - 1);
                switch (Character.toUpperCase(suffix)) {
                    case 'S':
                        mult = Constants.SECOND;
                        break;
                    case 'M':
                        mult = Constants.MINUTE;
                        break;
                    case 'H':
                        mult = Constants.HOUR;
                        break;
                    case 'D':
                        mult = Constants.DAY;
                        break;
                    case 'W':
                        mult = Constants.WEEK;
                        break;
                    default:
                        throw new NumberFormatException("Illegal time interval suffix");
                }
            }
            return Long.parseLong(numstr) * mult;
        } catch (IndexOutOfBoundsException e) {
            throw new NumberFormatException("empty string");
        }
    }