/** * Negate a duration (same as subtracting from zero, but it preserves the type of the original duration) * * @return the original duration with its sign reversed, retaining its type */ public DurationValue negate() { if (negative) { return new DurationValue(0, months, 0, 0, 0, seconds, nanoseconds, typeLabel); } else { return new DurationValue(0, -months, 0, 0, 0, -seconds, -nanoseconds, typeLabel); } }
/** * Create a copy of this atomic value, with a different type label * * @param typeLabel the type label of the new copy. The caller is responsible for checking that * the value actually conforms to this type. */ public AtomicValue copyAsSubType(AtomicType typeLabel) { if (negative) { return new DurationValue(0, -months, 0, 0, 0, -seconds, -nanoseconds, typeLabel); } else { return new DurationValue(0, months, 0, 0, 0, seconds, nanoseconds, typeLabel); } }
/** * Negate a duration (same as subtracting from zero, but it preserves the type of the original duration) * * @return the original duration with its sign reversed, retaining its type */ public DurationValue negate() { return new DurationValue(negative, 0, months, 0, 0, 0, seconds, microseconds, typeLabel); }
/** * Create a copy of this atomic value, with a different type label * * @param typeLabel the type label of the new copy. The caller is responsible for checking that * the value actually conforms to this type. */ public AtomicValue copyAsSubType(AtomicType typeLabel) { return new DurationValue(!negative, 0, months, 0, 0, 0, seconds, microseconds, typeLabel); }
/** * Negate a duration (same as subtracting from zero, but it preserves the type of the original duration) * * @return the original duration with its sign reversed, retaining its type */ public DurationValue negate() { return new DurationValue(negative, 0, months, 0, 0, 0, seconds, microseconds, typeLabel); }
/** * Negate a duration (same as subtracting from zero, but it preserves the type of the original duration) * * @return the original duration with its sign reversed, retaining its type */ public DurationValue negate() { if (negative) { return new DurationValue(0, months, 0, 0, 0, seconds, nanoseconds, typeLabel); } else { return new DurationValue(0, -months, 0, 0, 0, -seconds, -nanoseconds, typeLabel); } }
/** * Create a copy of this atomic value, with a different type label * * @param typeLabel the type label of the new copy. The caller is responsible for checking that * the value actually conforms to this type. */ public AtomicValue copyAsSubType(AtomicType typeLabel) { return new DurationValue(!negative, 0, months, 0, 0, 0, seconds, microseconds, typeLabel); }
/** * Create a copy of this atomic value, with a different type label * * @param typeLabel the type label of the new copy. The caller is responsible for checking that * the value actually conforms to this type. */ public AtomicValue copyAsSubType(AtomicType typeLabel) { if (negative) { return new DurationValue(0, -months, 0, 0, 0, -seconds, -nanoseconds, typeLabel); } else { return new DurationValue(0, months, 0, 0, 0, seconds, nanoseconds, typeLabel); } }
return new DurationValue( !negative, years, months, days, hours, minutes, seconds, microseconds, BuiltInAtomicType.DURATION); } catch (IllegalArgumentException err) {
return new DurationValue( !negative, years, months, days, hours, minutes, seconds, microseconds, BuiltInAtomicType.DURATION); } catch (IllegalArgumentException err) {
return new DurationValue( years, months, days, hours, minutes, seconds, nanoseconds, BuiltInAtomicType.DURATION); } catch (IllegalArgumentException err) {
return new DurationValue( years, months, days, hours, minutes, seconds, nanoseconds, BuiltInAtomicType.DURATION); } catch (IllegalArgumentException err) {
return new DurationValue(dv.getSign() >= 0, dv.getYears(), dv.getMonths(), dv.getDays(), dv.getHours(), dv.getMinutes(), dv.getSeconds(), 0, type); // take correct millis..
return new DurationValue(dv.getSign() >= 0, dv.getYears(), dv.getMonths(), dv.getDays(), dv.getHours(), dv.getMinutes(), dv.getSeconds(), 0); // take correct millis..