/** * Subtracts a duration value (which may be negative) from the instant. * * @param instant the milliseconds from 1970-01-01T00:00:00Z to subtract from * @param value the value to subtract, in the units of the field * @return the updated milliseconds * @since 1.1 */ public long subtract(long instant, int value) { if (value == Integer.MIN_VALUE) { return subtract(instant, (long) value); } return add(instant, -value); }
/** * Subtracts a duration value (which may be negative) from the instant. * * @param instant the milliseconds from 1970-01-01T00:00:00Z to subtract from * @param value the value to subtract, in the units of the field * @return the updated milliseconds * @since 1.1 */ public long subtract(long instant, int value) { if (value == Integer.MIN_VALUE) { return subtract(instant, (long) value); } return add(instant, -value); }
/** * Returns a copy of this datetime minus the specified number of hours. * <p> * This LocalDateTime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * LocalDateTime subtracted = dt.minusHours(6); * LocalDateTime subtracted = dt.minus(Period.hours(6)); * LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.hours(), -6); * </pre> * * @param hours the amount of hours to subtract, may be negative * @return the new LocalDateTime minus the increased hours */ public LocalDateTime minusHours(int hours) { if (hours == 0) { return this; } long instant = getChronology().hours().subtract(getLocalMillis(), hours); return withLocalMillis(instant); }
/** * Returns a copy of this time minus the specified number of minutes. * <p> * This LocalTime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * LocalTime subtracted = dt.minusMinutes(6); * LocalTime subtracted = dt.minus(Period.minutes(6)); * LocalTime subtracted = dt.withFieldAdded(DurationFieldType.minutes(), -6); * </pre> * * @param minutes the amount of minutes to subtract, may be negative * @return the new LocalTime minus the increased minutes */ public LocalTime minusMinutes(int minutes) { if (minutes == 0) { return this; } long instant = getChronology().minutes().subtract(getLocalMillis(), minutes); return withLocalMillis(instant); }
/** * Returns a copy of this time minus the specified number of millis. * <p> * This LocalTime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * LocalTime subtracted = dt.minusMillis(6); * LocalTime subtracted = dt.minus(Period.millis(6)); * LocalTime subtracted = dt.withFieldAdded(DurationFieldType.millis(), -6); * </pre> * * @param millis the amount of millis to subtract, may be negative * @return the new LocalTime minus the increased millis */ public LocalTime minusMillis(int millis) { if (millis == 0) { return this; } long instant = getChronology().millis().subtract(getLocalMillis(), millis); return withLocalMillis(instant); }
/** * Returns a copy of this date minus the specified number of days. * <p> * This LocalDate instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * LocalDate subtracted = dt.minusDays(6); * LocalDate subtracted = dt.minus(Period.days(6)); * LocalDate subtracted = dt.withFieldAdded(DurationFieldType.days(), -6); * </pre> * * @param days the amount of days to subtract, may be negative * @return the new LocalDate minus the increased days */ public LocalDate minusDays(int days) { if (days == 0) { return this; } long instant = getChronology().days().subtract(getLocalMillis(), days); return withLocalMillis(instant); }
/** * Returns a copy of this datetime minus the specified number of years. * <p> * This LocalDateTime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * LocalDateTime subtracted = dt.minusYears(6); * LocalDateTime subtracted = dt.minus(Period.years(6)); * LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.years(), -6); * </pre> * * @param years the amount of years to subtract, may be negative * @return the new LocalDateTime minus the increased years */ public LocalDateTime minusYears(int years) { if (years == 0) { return this; } long instant = getChronology().years().subtract(getLocalMillis(), years); return withLocalMillis(instant); }
/** * Returns a copy of this time minus the specified number of seconds. * <p> * This LocalTime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * LocalTime subtracted = dt.minusSeconds(6); * LocalTime subtracted = dt.minus(Period.seconds(6)); * LocalTime subtracted = dt.withFieldAdded(DurationFieldType.seconds(), -6); * </pre> * * @param seconds the amount of seconds to subtract, may be negative * @return the new LocalTime minus the increased seconds */ public LocalTime minusSeconds(int seconds) { if (seconds == 0) { return this; } long instant = getChronology().seconds().subtract(getLocalMillis(), seconds); return withLocalMillis(instant); }
/** * Returns a copy of this date minus the specified number of years. * <p> * This datetime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * DateTime subtracted = dt.minusYears(6); * DateTime subtracted = dt.minus(Period.years(6)); * DateTime subtracted = dt.withFieldAdded(DurationFieldType.years(), -6); * </pre> * * @param years the amount of years to subtract, may be negative * @return the new datetime minus the increased years * @since 1.1 */ public DateMidnight minusYears(int years) { if (years == 0) { return this; } long instant = getChronology().years().subtract(getMillis(), years); return withMillis(instant); }
/** * Returns a copy of this date minus the specified number of weeks. * <p> * This datetime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * DateMidnight subtracted = dt.minusWeeks(6); * DateMidnight subtracted = dt.minus(Period.weeks(6)); * DateMidnight subtracted = dt.withFieldAdded(DurationFieldType.weeks(), -6); * </pre> * * @param weeks the amount of weeks to subtract, may be negative * @return the new datetime minus the increased weeks * @since 1.1 */ public DateMidnight minusWeeks(int weeks) { if (weeks == 0) { return this; } long instant = getChronology().weeks().subtract(getMillis(), weeks); return withMillis(instant); }
/** * Returns a copy of this date minus the specified number of weeks. * <p> * This LocalDate instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * LocalDate subtracted = dt.minusWeeks(6); * LocalDate subtracted = dt.minus(Period.weeks(6)); * LocalDate subtracted = dt.withFieldAdded(DurationFieldType.weeks(), -6); * </pre> * * @param weeks the amount of weeks to subtract, may be negative * @return the new LocalDate minus the increased weeks */ public LocalDate minusWeeks(int weeks) { if (weeks == 0) { return this; } long instant = getChronology().weeks().subtract(getLocalMillis(), weeks); return withLocalMillis(instant); }
/** * Returns a copy of this datetime minus the specified number of months. * <p> * This LocalDateTime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * LocalDateTime subtracted = dt.minusMonths(6); * LocalDateTime subtracted = dt.minus(Period.months(6)); * LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.months(), -6); * </pre> * * @param months the amount of months to subtract, may be negative * @return the new LocalDateTime minus the increased months */ public LocalDateTime minusMonths(int months) { if (months == 0) { return this; } long instant = getChronology().months().subtract(getLocalMillis(), months); return withLocalMillis(instant); }
/** * Returns a copy of this datetime minus the specified number of millis. * <p> * This LocalDateTime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * LocalDateTime subtracted = dt.minusMillis(6); * LocalDateTime subtracted = dt.minus(Period.millis(6)); * LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.millis(), -6); * </pre> * * @param millis the amount of millis to subtract, may be negative * @return the new LocalDateTime minus the increased millis */ public LocalDateTime minusMillis(int millis) { if (millis == 0) { return this; } long instant = getChronology().millis().subtract(getLocalMillis(), millis); return withLocalMillis(instant); }
/** * Returns a copy of this datetime minus the specified number of weeks. * <p> * This LocalDateTime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * LocalDateTime subtracted = dt.minusWeeks(6); * LocalDateTime subtracted = dt.minus(Period.weeks(6)); * LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.weeks(), -6); * </pre> * * @param weeks the amount of weeks to subtract, may be negative * @return the new LocalDateTime minus the increased weeks */ public LocalDateTime minusWeeks(int weeks) { if (weeks == 0) { return this; } long instant = getChronology().weeks().subtract(getLocalMillis(), weeks); return withLocalMillis(instant); }
/** * Returns a copy of this datetime minus the specified number of seconds. * <p> * This LocalDateTime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * LocalDateTime subtracted = dt.minusSeconds(6); * LocalDateTime subtracted = dt.minus(Period.seconds(6)); * LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.seconds(), -6); * </pre> * * @param seconds the amount of seconds to subtract, may be negative * @return the new LocalDateTime minus the increased seconds */ public LocalDateTime minusSeconds(int seconds) { if (seconds == 0) { return this; } long instant = getChronology().seconds().subtract(getLocalMillis(), seconds); return withLocalMillis(instant); }
/** * Returns a copy of this time minus the specified number of hours. * <p> * This LocalTime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * LocalTime subtracted = dt.minusHours(6); * LocalTime subtracted = dt.minus(Period.hours(6)); * LocalTime subtracted = dt.withFieldAdded(DurationFieldType.hours(), -6); * </pre> * * @param hours the amount of hours to subtract, may be negative * @return the new LocalTime minus the increased hours */ public LocalTime minusHours(int hours) { if (hours == 0) { return this; } long instant = getChronology().hours().subtract(getLocalMillis(), hours); return withLocalMillis(instant); }
/** * Returns a copy of this datetime minus the specified number of days. * <p> * This LocalDateTime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * LocalDateTime subtracted = dt.minusDays(6); * LocalDateTime subtracted = dt.minus(Period.days(6)); * LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.days(), -6); * </pre> * * @param days the amount of days to subtract, may be negative * @return the new LocalDateTime minus the increased days */ public LocalDateTime minusDays(int days) { if (days == 0) { return this; } long instant = getChronology().days().subtract(getLocalMillis(), days); return withLocalMillis(instant); }
/** * Returns a copy of this datetime minus the specified number of minutes. * <p> * This LocalDateTime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * LocalDateTime subtracted = dt.minusMinutes(6); * LocalDateTime subtracted = dt.minus(Period.minutes(6)); * LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.minutes(), -6); * </pre> * * @param minutes the amount of minutes to subtract, may be negative * @return the new LocalDateTime minus the increased minutes */ public LocalDateTime minusMinutes(int minutes) { if (minutes == 0) { return this; } long instant = getChronology().minutes().subtract(getLocalMillis(), minutes); return withLocalMillis(instant); }
/** * Returns a copy of this date minus the specified number of months. * <p> * This datetime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * DateMidnight subtracted = dt.minusMonths(6); * DateMidnight subtracted = dt.minus(Period.months(6)); * DateMidnight subtracted = dt.withFieldAdded(DurationFieldType.months(), -6); * </pre> * * @param months the amount of months to subtract, may be negative * @return the new datetime minus the increased months * @since 1.1 */ public DateMidnight minusMonths(int months) { if (months == 0) { return this; } long instant = getChronology().months().subtract(getMillis(), months); return withMillis(instant); }
/** * Returns a copy of this date minus the specified number of days. * <p> * This datetime instance is immutable and unaffected by this method call. * <p> * The following three lines are identical in effect: * <pre> * DateMidnight subtracted = dt.minusDays(6); * DateMidnight subtracted = dt.minus(Period.days(6)); * DateMidnight subtracted = dt.withFieldAdded(DurationFieldType.days(), -6); * </pre> * * @param days the amount of days to subtract, may be negative * @return the new datetime minus the increased days * @since 1.1 */ public DateMidnight minusDays(int days) { if (days == 0) { return this; } long instant = getChronology().days().subtract(getMillis(), days); return withMillis(instant); }