/** * Creates a new instance of the object described by this field. * * @param parent The object for which the field is created * @return A new instance of the field's value * @throws IllegalStateException This field is a simple type and cannot be instantiated */ public Object newInstance(Object parent) throws IllegalStateException { return new GMonth(); } // -- newInstance
/** * Creates a new instance of the object described by this field. * * @param parent The object for which the field is created * @return A new instance of the field's value * @throws IllegalStateException This field is a simple type and * cannot be instantiated */ public Object newInstance(Object parent) throws IllegalStateException { return new GMonth(); } //-- newInstance
/** * parse a String and convert it into a GMonth. * * @param str the string to parse * @return the Date represented by the string * @throws ParseException a parse exception is thrown if the string to parse does not follow the * rigth format (see the description of this class) */ public static GMonth parseGMonth(String str) throws ParseException { GMonth result = new GMonth(); return parseGMonthInternal(str, result); }
/** * parse a String and convert it into a GMonth. * @param str the string to parse * @return the Date represented by the string * @throws ParseException a parse exception is thrown if the string to parse * does not follow the rigth format (see the description * of this class) */ public static GMonth parseGMonth(String str) throws ParseException { GMonth result = new GMonth(); return parseGMonthInternal(str, result); }
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