private static GMonth parseGMonthInternal(String str, GMonth result) throws ParseException { if (str == null) { throw new IllegalArgumentException("The string to be parsed must not be null."); } if (result == null) { result = new GMonth(); } char[] chars = str.toCharArray(); int idx = 0; if (chars[0] != '-' || chars[1] != '-') { throw new ParseException(BAD_GMONTH+str+"\nA gMonth must follow the pattern --DD--(Z|((+|-)hh:mm)).", 0); } idx += 2; // Month if (!Character.isDigit(chars[idx]) || !Character.isDigit(chars[idx + 1])) { throw new ParseException(BAD_GMONTH+str+"\nThe Month must be 2 digits long", idx); } short value1 = (short) ((chars[idx] - '0') * 10 + (chars[idx+1] - '0')); result.setMonth(value1); idx += 2; if (chars[idx] != '-' || chars[idx+1] != '-') { throw new ParseException(BAD_GMONTH+str+"\nA gMonth must follow the pattern --DD--(Z|((+|-)hh:mm)).", 0); } idx += 2; parseTimeZone(str, result, chars, idx, BAD_GMONTH); return result; } //parse
private static GMonth parseGMonthInternal(String str, GMonth result) throws ParseException { if (str == null) { throw new IllegalArgumentException("The string to be parsed must not be null."); } if (result == null) { result = new GMonth(); } char[] chars = str.toCharArray(); int idx = 0; if (chars[0] != '-' || chars[1] != '-') { throw new ParseException( BAD_GMONTH + str + "\nA gMonth must follow the pattern --DD--(Z|((+|-)hh:mm)).", 0); } idx += 2; // Month if (!Character.isDigit(chars[idx]) || !Character.isDigit(chars[idx + 1])) { throw new ParseException(BAD_GMONTH + str + "\nThe Month must be 2 digits long", idx); } short value1 = (short) ((chars[idx] - '0') * 10 + (chars[idx + 1] - '0')); result.setMonth(value1); idx += 2; if (chars[idx] != '-' || chars[idx + 1] != '-') { throw new ParseException( BAD_GMONTH + str + "\nA gMonth must follow the pattern --DD--(Z|((+|-)hh:mm)).", 0); } idx += 2; parseTimeZone(str, result, chars, idx, BAD_GMONTH); return result; } // parse