private static Time parseTimeInternal(String str, Time result) throws ParseException { if (str == null) { throw new IllegalArgumentException("The string to be parsed must not be null."); } if (result == null) { result = new Time(); } char[] chars = str.toCharArray(); int idx = parseTime(str, result, chars, 0, BAD_TIME); parseTimeZone(str, result, chars, idx, BAD_TIME); return result; } // parse
/** * convert this Time to a string The format is defined by W3C XML Schema Recommendation and * ISO8601 i.e hh:mm:ss.sss(Z|(+|-)hh:mm) * * @return a string representing this Time */ public String toString() { StringBuffer result = new StringBuffer(); appendTimeString(result); appendTimeZoneString(result); return result.toString(); } // toString
/** * Converts this Time instance into a long value based on UTC time zone. * * @return A long value representing this Time instance. */ public long toLong() { int sign = isZoneNegative() ? 1 : -1; int hour = getHour() + sign * getZoneHour(); int minute = getMinute() + sign * getZoneMinute(); int second = getSeconds(); int milli = getMilli(); if (minute < 0) { minute = minute + 60; hour = hour - 1; } else if (minute > 59) { minute = minute - 60; hour = hour + 1; } if (hour < 0) { hour = hour + 24; } else if (hour > 23) { hour = hour - 24; } return 3600000 * hour + 60000 * minute + 1000 * second + milli; }
/** * returns an array of short with all the fields that describe this time type. * <p> * Note:the time zone is not included. * * @return an array of short with all the fields that describe this time type. */ public short[] getValues() { short[] result = new short[4]; result[0] = this.getHour(); result[1] = this.getMinute(); result[2] = this.getSeconds(); result[3] = this.getMilli(); return result; } // getValues
Time temp = Time.parseTime(value.toString()) ; timeTarget.setHour(temp.getHour()); timeTarget.setMinute(temp.getMinute()); timeTarget.setSecond(temp.getSeconds(), temp.getMilli()); if (temp.isUTC()) { timeTarget.setUTC(); timeTarget.setZone(temp.getZoneHour(),temp.getZoneMinute()); timeTarget.setZoneNegative(temp.isZoneNegative());
/** * parses a String and converts it into a java.lang.Object * * @param str the string to parse * @return the java.lang.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 parseTime(str); }
/** * 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 Time(); } // -- newInstance
Time temp = Time.parseTime(value.toString()); timeTarget.setHour(temp.getHour()); timeTarget.setMinute(temp.getMinute()); timeTarget.setSecond(temp.getSeconds(), temp.getMilli()); if (temp.isUTC()) { timeTarget.setUTC(); timeTarget.setZone(temp.getZoneHour(), temp.getZoneMinute()); timeTarget.setZoneNegative(temp.isZoneNegative());
/** * returns an array of short with all the fields that describe * this time type. * <p>Note:the time zone is not included. * @return an array of short with all the fields that describe * this time type. */ public short[] getValues() { short[] result = new short[4]; result[0] = this.getHour(); result[1] = this.getMinute(); result[2] = this.getSeconds(); result[3] = this.getMilli(); return result; } //getValues
/** * parses a String and converts it into a java.lang.Object * @param str the string to parse * @return the java.lang.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 parseTime(str); }
/** * 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 Time(); } //-- newInstance
private static Time parseTimeInternal(String str, Time result) throws ParseException { if (str == null) { throw new IllegalArgumentException("The string to be parsed must not be null."); } if (result == null) { result = new Time(); } char[] chars = str.toCharArray(); int idx = parseTime(str, result, chars, 0, BAD_TIME); parseTimeZone(str, result, chars, idx, BAD_TIME); return result; } //parse
Time.parseTime(value); return TIME_TYPE; } catch (ParseException px) {
/** * {@inheritDoc} */ public Object convert(final Object object) { return new org.exolab.castor.types.Time(((Long) object).longValue(), _utc); }
/** * convert this Time to a string * The format is defined by W3C XML Schema Recommendation and ISO8601 * i.e hh:mm:ss.sss(Z|(+|-)hh:mm) * @return a string representing this Time */ public String toString() { StringBuffer result = new StringBuffer(); appendTimeString(result); appendTimeZoneString(result); return result.toString(); } //toString
Time.parseTime(value); return TIME_TYPE;
/** * {@inheritDoc} */ public Object convert(final Object object) { try { return new org.exolab.castor.types.Time((String) object); } catch (ParseException ex) { throw new IllegalArgumentException(ex.toString()); } }