/** * 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 GYear(); } // -- 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 GYear(); } //-- newInstance
private static GYear parseGYearInternal(String str, GYear result) throws ParseException{ if (str == null) { throw new IllegalArgumentException("The string to be parsed must not be null."); } if (result == null) { result = new GYear(); } char[] chars = str.toCharArray(); int idx = 0; // Negative? if (chars[idx] == '-') { result.setNegative(); idx++; } // Century if (!Character.isDigit(chars[idx]) || !Character.isDigit(chars[idx + 1]) || !Character.isDigit(chars[idx + 2]) || !Character.isDigit(chars[idx + 3])) { throw new ParseException(BAD_GYEAR+str+"\nA gYear must follow the pattern CCYY(Z|((+|-)hh:mm)).",idx); } short value1 = (short) ((chars[idx] - '0') * 10 + (chars[idx+1] - '0')); short value2 = (short) ((chars[idx+2] - '0') * 10 + (chars[idx+3] - '0')); if (value1 == 0 && value2 == 0) { throw new ParseException(BAD_GYEAR+str+"\n'0000' is not allowed as a year.", idx); } result.setCentury(value1); result.setYear(value2); idx += 4; parseTimeZone(str, result, chars, idx, BAD_GYEAR); return result; }//parse
result = new GYear();