/** * 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
/** * Returns an array of short with all the fields that describe * this gYear type. * <p>Note:the time zone is not included. * @return an array of short with all the fields that describe * this Date type. */ public short[] getValues() { short[] result = new short[2]; result[0] = this.getCentury(); result[1] = this.getYear(); return result; } //getValues
/** * parse a String and convert it into an java.lang.Object * * @param str the string to parse * @return an Object 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 Object parse(String str) throws ParseException { return parseGYear(str); }
GYear temp = GYear.parseGYear(value.toString()) ; GYearTarget.setCentury(temp.getCentury()); GYearTarget.setYear(temp.getYear()); if (temp.isUTC()) { GYearTarget.setUTC(); GYearTarget.setZone(temp.getZoneHour(), temp.getZoneMinute()); GYearTarget.setZoneNegative(temp.isZoneNegative());
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
/** * convert this gYear to a string The format is defined by W3C XML Schema recommendation and * ISO8601 i.e (+|-)CCYY-MM(Z|(+|-)hh:mm) * * @return a string representing this Date */ public String toString() { StringBuffer result = new StringBuffer(); if (isNegative()) { result.append('-'); } if ((this.getCentury() / 10) == 0) { result.append(0); } result.append(this.getCentury()); if ((this.getYear() / 10) == 0) { result.append(0); } result.append(this.getYear()); appendTimeZoneString(result); return result.toString(); }// toString
GYear temp = GYear.parseGYear(value.toString()); GYearTarget.setCentury(temp.getCentury()); GYearTarget.setYear(temp.getYear()); if (temp.isUTC()) { GYearTarget.setUTC(); GYearTarget.setZone(temp.getZoneHour(), temp.getZoneMinute()); GYearTarget.setZoneNegative(temp.isZoneNegative());
result = new GYear(); result.setNegative(); idx++; result.setCentury(value1); result.setYear(value2); parseTimeZone(str, result, chars, idx, BAD_GYEAR);
/** * convert this gYear to a string * The format is defined by W3C XML Schema recommendation and ISO8601 * i.e (+|-)CCYY-MM(Z|(+|-)hh:mm) * @return a string representing this Date */ public String toString() { StringBuffer result = new StringBuffer(); if (isNegative()) { result.append('-'); } if ((this.getCentury()/10) == 0) { result.append(0); } result.append(this.getCentury()); if ((this.getYear()/10) == 0) { result.append(0); } result.append(this.getYear()); appendTimeZoneString(result); return result.toString(); }//toString
/** * Returns an array of short with all the fields that describe this gYear type. * <p> * Note:the time zone is not included. * * @return an array of short with all the fields that describe this Date type. */ public short[] getValues() { short[] result = new short[2]; result[0] = this.getCentury(); result[1] = this.getYear(); return result; } // getValues
/** * 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
/** * parse a String and convert it into an java.lang.Object * @param str the string to parse * @return an Object 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 Object parse(String str) throws ParseException { return parseGYear(str); }