/** * Returns a copy of this datetime plus the specified number of seconds. * <p> * The calculation will add a duration equivalent to the number of seconds * expressed in milliseconds. * <p> * The following three lines are identical in effect: * <pre> * DateTime added = dt.plusSeconds(6); * DateTime added = dt.plus(Period.seconds(6)); * DateTime added = dt.withFieldAdded(DurationFieldType.seconds(), 6); * </pre> * <p> * This datetime instance is immutable and unaffected by this method call. * * @param seconds the amount of seconds to add, may be negative * @return the new datetime plus the increased seconds * @since 1.1 */ public DateTime plusSeconds(int seconds) { if (seconds == 0) { return this; } long instant = getChronology().seconds().add(getMillis(), seconds); return withMillis(instant); }
/** * Returns a copy of this datetime minus the specified number of seconds. * <p> * The calculation will subtract a duration equivalent to the number of * seconds expressed in milliseconds. * <p> * The following three lines are identical in effect: * <pre> * DateTime subtracted = dt.minusSeconds(6); * DateTime subtracted = dt.minus(Period.seconds(6)); * DateTime subtracted = dt.withFieldAdded(DurationFieldType.seconds(), -6); * </pre> * <p> * This datetime instance is immutable and unaffected by this method call. * * @param seconds the amount of seconds to subtract, may be negative * @return the new datetime minus the increased seconds * @since 1.1 */ public DateTime minusSeconds(int seconds) { if (seconds == 0) { return this; } long instant = getChronology().seconds().subtract(getMillis(), seconds); return withMillis(instant); }
/** * Returns a copy of this datetime plus the specified number of seconds. * <p> * The calculation will add a duration equivalent to the number of seconds * expressed in milliseconds. * <p> * The following three lines are identical in effect: * <pre> * DateTime added = dt.plusSeconds(6); * DateTime added = dt.plus(Period.seconds(6)); * DateTime added = dt.withFieldAdded(DurationFieldType.seconds(), 6); * </pre> * <p> * This datetime instance is immutable and unaffected by this method call. * * @param seconds the amount of seconds to add, may be negative * @return the new datetime plus the increased seconds * @since 1.1 */ public DateTime plusSeconds(int seconds) { if (seconds == 0) { return this; } long instant = getChronology().seconds().add(getMillis(), seconds); return withMillis(instant); }
/** * Returns a copy of this datetime minus the specified number of seconds. * <p> * The calculation will subtract a duration equivalent to the number of * seconds expressed in milliseconds. * <p> * The following three lines are identical in effect: * <pre> * DateTime subtracted = dt.minusSeconds(6); * DateTime subtracted = dt.minus(Period.seconds(6)); * DateTime subtracted = dt.withFieldAdded(DurationFieldType.seconds(), -6); * </pre> * <p> * This datetime instance is immutable and unaffected by this method call. * * @param seconds the amount of seconds to subtract, may be negative * @return the new datetime minus the increased seconds * @since 1.1 */ public DateTime minusSeconds(int seconds) { if (seconds == 0) { return this; } long instant = getChronology().seconds().subtract(getMillis(), seconds); return withMillis(instant); }
/** * Add a number of seconds to the date. * * @param seconds the seconds to add * @throws IllegalArgumentException if the value is invalid */ public void addSeconds(final int seconds) { if (seconds != 0) { setMillis(getChronology().seconds().add(getMillis(), seconds)); } }
/** * Add a number of seconds to the date. * * @param seconds the seconds to add * @throws IllegalArgumentException if the value is invalid */ public void addSeconds(final int seconds) { if (seconds != 0) { setMillis(getChronology().seconds().add(getMillis(), seconds)); } }
/** * Returns a copy of this time plus 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 added = dt.plusSeconds(6); * LocalTime added = dt.plus(Period.seconds(6)); * LocalTime added = dt.withFieldAdded(DurationFieldType.seconds(), 6); * </pre> * * @param seconds the amount of seconds to add, may be negative * @return the new LocalTime plus the increased seconds */ public LocalTime plusSeconds(int seconds) { if (seconds == 0) { return this; } long instant = getChronology().seconds().add(getLocalMillis(), seconds); 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 datetime plus 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 added = dt.plusSeconds(6); * LocalDateTime added = dt.plus(Period.seconds(6)); * LocalDateTime added = dt.withFieldAdded(DurationFieldType.seconds(), 6); * </pre> * * @param seconds the amount of seconds to add, may be negative * @return the new LocalDateTime plus the increased seconds */ public LocalDateTime plusSeconds(int seconds) { if (seconds == 0) { return this; } long instant = getChronology().seconds().add(getLocalMillis(), seconds); 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 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 datetime plus 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 added = dt.plusSeconds(6); * LocalDateTime added = dt.plus(Period.seconds(6)); * LocalDateTime added = dt.withFieldAdded(DurationFieldType.seconds(), 6); * </pre> * * @param seconds the amount of seconds to add, may be negative * @return the new LocalDateTime plus the increased seconds */ public LocalDateTime plusSeconds(int seconds) { if (seconds == 0) { return this; } long instant = getChronology().seconds().add(getLocalMillis(), seconds); return withLocalMillis(instant); }
/** * Returns a copy of this time plus 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 added = dt.plusSeconds(6); * LocalTime added = dt.plus(Period.seconds(6)); * LocalTime added = dt.withFieldAdded(DurationFieldType.seconds(), 6); * </pre> * * @param seconds the amount of seconds to add, may be negative * @return the new LocalTime plus the increased seconds */ public LocalTime plusSeconds(int seconds) { if (seconds == 0) { return this; } long instant = getChronology().seconds().add(getLocalMillis(), seconds); 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); }
/** * Creates a <code>Seconds</code> representing the number of whole seconds * between the two specified partial datetimes. * <p> * The two partials must contain the same fields, for example you can specify * two <code>LocalTime</code> objects. * * @param start the start partial date, must not be null * @param end the end partial date, must not be null * @return the period in seconds * @throws IllegalArgumentException if the partials are null or invalid */ public static Seconds secondsBetween(ReadablePartial start, ReadablePartial end) { if (start instanceof LocalTime && end instanceof LocalTime) { Chronology chrono = DateTimeUtils.getChronology(start.getChronology()); int seconds = chrono.seconds().getDifference( ((LocalTime) end).getLocalMillis(), ((LocalTime) start).getLocalMillis()); return Seconds.seconds(seconds); } int amount = BaseSingleFieldPeriod.between(start, end, ZERO); return Seconds.seconds(amount); }
/** * Creates a <code>Seconds</code> representing the number of whole seconds * between the two specified partial datetimes. * <p> * The two partials must contain the same fields, for example you can specify * two <code>LocalTime</code> objects. * * @param start the start partial date, must not be null * @param end the end partial date, must not be null * @return the period in seconds * @throws IllegalArgumentException if the partials are null or invalid */ public static Seconds secondsBetween(ReadablePartial start, ReadablePartial end) { if (start instanceof LocalTime && end instanceof LocalTime) { Chronology chrono = DateTimeUtils.getChronology(start.getChronology()); int seconds = chrono.seconds().getDifference( ((LocalTime) end).getLocalMillis(), ((LocalTime) start).getLocalMillis()); return Seconds.seconds(seconds); } int amount = BaseSingleFieldPeriod.between(start, end, ZERO); return Seconds.seconds(amount); }
return chronology.minutes(); case SECONDS: return chronology.seconds(); case MILLIS: return chronology.millis();
return chronology.minutes(); case SECONDS: return chronology.seconds(); case MILLIS: return chronology.millis();
millis = f; if (isSupported(f = chrono.seconds())) { seconds = f;