/** * Returns the sign of this duration in -1,0, or 1. * * @return -1 if this duration is negative, 0 if the duration is zero, * and 1 if the duration is positive. */ public int getSign() { return duration.signum(); }
/** * Returns the sign of this duration in -1,0, or 1. * * @return -1 if this duration is negative, 0 if the duration is zero, * and 1 if the duration is positive. */ public int getSign() { return duration.signum(); }
/** * Static factory: create a year-month duration value from a supplied string, in * ISO 8601 format [+|-]PnYnM * * @param s a string in the lexical space of xs:yearMonthDuration. * @return either a YearMonthDurationValue, or a ValidationFailure if the string was * not in the lexical space of xs:yearMonthDuration. */ public static ConversionResult makeYearMonthDurationValue(CharSequence s) { ConversionResult d = DurationValue.makeDuration(s, true, false); if (d instanceof ValidationFailure) { return d; } DurationValue dv = (DurationValue) d; return YearMonthDurationValue.fromMonths((dv.getYears() * 12 + dv.getMonths()) * dv.signum()); }
/** * Static factory: create a year-month duration value from a supplied string, in * ISO 8601 format [+|-]PnYnM * * @param s a string in the lexical space of xs:yearMonthDuration. * @return either a YearMonthDurationValue, or a ValidationFailure if the string was * not in the lexical space of xs:yearMonthDuration. */ public static ConversionResult makeYearMonthDurationValue(CharSequence s) { ConversionResult d = DurationValue.makeDuration(s, true, false); if (d instanceof ValidationFailure) { return d; } DurationValue dv = (DurationValue) d; return YearMonthDurationValue.fromMonths((dv.getYears() * 12 + dv.getMonths()) * dv.signum()); }
public DayTimeDurationValue convert(AtomicValue duration) { DurationValue d = (DurationValue)duration; if (d.signum() < 0) { return new DayTimeDurationValue(-d.getDays(), -d.getHours(), -d.getMinutes(), -d.getSeconds(), -d.getNanoseconds()); } else { return new DayTimeDurationValue(d.getDays(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getNanoseconds()); } } }
public DayTimeDurationValue convert(AtomicValue duration) { DurationValue d = (DurationValue)duration; if (d.signum() < 0) { return new DayTimeDurationValue(-d.getDays(), -d.getHours(), -d.getMinutes(), -d.getSeconds(), -d.getNanoseconds()); } else { return new DayTimeDurationValue(d.getDays(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getNanoseconds()); } } }