/** * Sets the value of the field associated with this descriptor. * @param target the object in which to set the value * @param value the value of the field */ public void setValue(Object target, Object value) throws java.lang.IllegalStateException { if (! (target instanceof Duration)) { String err = "DurationDescriptor#setValue: expected Duration, received instead: " + target.getClass(); throw new IllegalStateException(err); } Duration time = (Duration) target; if (value == null) { String err = "DurationDescriptor#setValue: null value"; throw new IllegalStateException(err); } //-- update current instance of time with new time try { Duration temp = Duration.parseDuration(value.toString()) ; time.setYear(temp.getYear()); time.setMonth(temp.getMonth()); time.setDay(temp.getDay()); time.setHour(temp.getHour()); time.setMinute(temp.getMinute()); time.setSeconds(temp.getSeconds()); time.setMilli(temp.getMilli()); } catch (java.text.ParseException ex) { throw new IllegalStateException(); } } //-- setValue
Duration temp = Duration.parseDuration(value.toString()); time.setYear(temp.getYear()); time.setMonth(temp.getMonth()); time.setDay(temp.getDay()); time.setHour(temp.getHour());
/** * Returns true if the instance of TimeDuration has the same fields of the parameter * * @param duration the time duration to compare * @return true if equal, false if not */ public boolean equal(Duration duration) { boolean result = false; if (duration == null) { return result; } result = (_year == duration.getYear()); result = result && (_month == duration.getMonth()); result = result && (_day == duration.getDay()); result = result && (_hour == duration.getHour()); result = result && (_minute == duration.getMinute()); result = result && (_second == duration.getSeconds()); result = result && (_millisecond == duration.getMilli()); result = result && (this.isNegative() == duration.isNegative()); return result; } // equals
/** * Returns true if the instance of TimeDuration has the same fields * of the parameter * @param duration the time duration to compare * @return true if equal, false if not */ public boolean equal(Duration duration) { boolean result = false; if (duration == null) { return result; } result = (_year == duration.getYear()); result = result && (_month == duration.getMonth()); result = result && (_day == duration.getDay()); result = result && (_hour == duration.getHour()); result = result && (_minute == duration.getMinute()); result = result && (_second == duration.getSeconds()); result = result && (_millisecond == duration.getMilli()); result = result && (this.isNegative() == duration.isNegative()); return result; } //equals
temp = _month + sign * duration.getMonth(); carry = fQuotient(temp - 1, 12); this.setMonth((short) (modulo(temp - 1, 12) + 1));
temp = _month + sign * duration.getMonth(); carry = fQuotient(temp - 1, 12); this.setMonth((short) (modulo(temp - 1, 12) + 1));