class MDateAndTime {

    public static DateTimeZone parseTimeZone(String tz) {
        try {
            Matcher m = TZ_PATTERN.matcher(tz);
            if(m.matches()) {
                int hourSign = "-".equals(m.group(TZ_SIGN_GROUP)) ? -1 : 1;
                int hour = Integer.parseInt(m.group(TZ_HOUR_GROUP));
                int min = Integer.parseInt(m.group(TZ_MINUTE_GROUP));
                return DateTimeZone.forOffsetHoursMinutes(hourSign * hour, min);
            } else {
                // Upper 'utc' but not 'America/New_York'
                if(tz.indexOf('/') == -1) {
                    tz = tz.toUpperCase();
                }
                return DateTimeZone.forID(tz);
            }
        } catch(IllegalArgumentException e) {
            throw new InvalidDateFormatException("timezone", tz);
        }
    }

}