public long add(long instant, int value) { long addition = value * iUnitMillis; // safe return FieldUtils.safeAdd(instant, addition); }
public long add(long instant, long value) { return FieldUtils.safeAdd(instant, value); }
public long add(long instant, int value) { return FieldUtils.safeAdd(instant, value); }
public long add(long instant, int value) { long addition = value * iUnitMillis; // safe return FieldUtils.safeAdd(instant, addition); }
public long add(long instant, long value) { long addition = FieldUtils.safeMultiply(value, iUnitMillis); return FieldUtils.safeAdd(instant, addition); }
public long add(long instant, long value) { long addition = FieldUtils.safeMultiply(value, iUnitMillis); return FieldUtils.safeAdd(instant, addition); }
/** * Sets the duration of this time interval, preserving the end instant. * * @param duration new duration for interval * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the start instant exceeds the capacity of a long */ public void setDurationBeforeEnd(long duration) { setStartMillis(FieldUtils.safeAdd(getEndMillis(), -duration)); }
/** * Add an amount of time to the datetime. * * @param duration the millis to add * @throws ArithmeticException if the result exceeds the capacity of the instant */ public void add(long duration) { setMillis(FieldUtils.safeAdd(getMillis(), duration)); // set via this class not super }
/** * Sets the duration of this time interval, preserving the start instant. * * @param duration new duration for interval * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the end instant exceeds the capacity of a long */ public void setDurationAfterStart(long duration) { setEndMillis(FieldUtils.safeAdd(getStartMillis(), duration)); }
public long add(long instant, int years) { if (years == 0) { return instant; } int thisYear = get(instant); int newYear = FieldUtils.safeAdd(thisYear, years); return set(instant, newYear); }
public long add(long instant, int years) { if (years == 0) { return instant; } int thisYear = get(instant); int newYear = FieldUtils.safeAdd(thisYear, years); return set(instant, newYear); }
/** * Add an amount of time to the datetime. * * @param duration the millis to add * @throws ArithmeticException if the result exceeds the capacity of the instant */ public void add(long duration) { setMillis(FieldUtils.safeAdd(getMillis(), duration)); // set via this class not super }
/** * Sets the duration of this time interval, preserving the end instant. * * @param duration new duration for interval * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the start instant exceeds the capacity of a long */ public void setDurationBeforeEnd(long duration) { setStartMillis(FieldUtils.safeAdd(getEndMillis(), -duration)); }
/** * Sets the duration of this time interval, preserving the start instant. * * @param duration new duration for interval * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the end instant exceeds the capacity of a long */ public void setDurationAfterStart(long duration) { setEndMillis(FieldUtils.safeAdd(getStartMillis(), duration)); }
/** * Returns a new instance with the specified number of weeks added. * <p> * This instance is immutable and unaffected by this method call. * * @param weeks the amount of weeks to add, may be negative * @return the new period plus the specified number of weeks * @throws ArithmeticException if the result overflows an int */ public Weeks plus(int weeks) { if (weeks == 0) { return this; } return Weeks.weeks(FieldUtils.safeAdd(getValue(), weeks)); }
/** * Returns a new instance with the specified number of days added. * <p> * This instance is immutable and unaffected by this method call. * * @param days the amount of days to add, may be negative * @return the new period plus the specified number of days * @throws ArithmeticException if the result overflows an int */ public Days plus(int days) { if (days == 0) { return this; } return Days.days(FieldUtils.safeAdd(getValue(), days)); }
/** * Sets the duration of this time interval, preserving the start instant. * * @param duration new duration for interval, null means zero length * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the end instant exceeds the capacity of a long */ public void setDurationAfterStart(ReadableDuration duration) { long durationMillis = DateTimeUtils.getDurationMillis(duration); setEndMillis(FieldUtils.safeAdd(getStartMillis(), durationMillis)); }
/** * Sets the duration of this time interval, preserving the end instant. * * @param duration new duration for interval, null means zero length * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the start instant exceeds the capacity of a long */ public void setDurationBeforeEnd(ReadableDuration duration) { long durationMillis = DateTimeUtils.getDurationMillis(duration); setStartMillis(FieldUtils.safeAdd(getEndMillis(), -durationMillis)); }
/** * Sets the duration of this time interval, preserving the start instant. * * @param duration new duration for interval, null means zero length * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the end instant exceeds the capacity of a long */ public void setDurationAfterStart(ReadableDuration duration) { long durationMillis = DateTimeUtils.getDurationMillis(duration); setEndMillis(FieldUtils.safeAdd(getStartMillis(), durationMillis)); }
/** * Sets the duration of this time interval, preserving the end instant. * * @param duration new duration for interval, null means zero length * @throws IllegalArgumentException if the end is before the start * @throws ArithmeticException if the start instant exceeds the capacity of a long */ public void setDurationBeforeEnd(ReadableDuration duration) { long durationMillis = DateTimeUtils.getDurationMillis(duration); setStartMillis(FieldUtils.safeAdd(getEndMillis(), -durationMillis)); }