public static ParsedDuration parse(String durationStr) throws ServiceException { if (durationStr == null) return null; ParsedDuration retVal = new ParsedDuration();  Matcher m = sDurationWeekPattern.matcher(durationStr); if (m.matches()) { String p = m.group(1); String wk = m.group(2);  if (p.charAt(0) == '-') { retVal.mNegative = true; retVal.mWeeks = Integer.parseInt(wk); }
public static ParsedDuration parse(boolean negative, int weeks, int days, int hours, int mins, int secs) { ParsedDuration toRet = new ParsedDuration(); assert(hours < 24); assert(mins < 60); assert(secs < 60); if (negative) { toRet.mNegative = true;
    public static ParsedDuration parse(String durationStr) throws ServiceException {        if (durationStr == null)            return null;        ParsedDuration retVal = new ParsedDuration();                Matcher m = sDurationWeekPattern.matcher(durationStr);        if (m.matches()) {            String p = m.group(1);            String wk = m.group(2);                        if (p.charAt(0) == '-') {                retVal.mNegative = true;                retVal.mWeeks = Integer.parseInt(wk);            }                    } else {            m = sDurationDayTimePattern.matcher(durationStr);            if (m.matches()) {                // P, Days, Hours, Mins, Secs                String p = m.group(1);                if (p.charAt(0) == '-') {                    retVal.mNegative = true;                }                String da = m.group(2);                if (da != null) {                    retVal.mDays = Integer.parseInt(da);                }                String ho = m.group(3);                if (ho!= null) {                    retVal.mHours = Integer.parseInt(ho);                }                String mi = m.group(4);                if (mi != null) {                    retVal.mMins = Integer.parseInt(mi);                }                String se = m.group(5);                if (se!= null) {                    retVal.mSecs = Integer.parseInt(se);                }            } else {                throw ServiceException.INVALID_REQUEST("Could not parse DURATION string: "+durationStr, null);            }        }        assert(retVal.mHours < 24);        assert(retVal.mMins < 60);        assert(retVal.mSecs < 60);                return retVal;    }