/** * Returns a copy of this {@code ZonedDateTime} with the specified period in minutes added. * <p> * This operates on the instant time-line, such that adding one minute will * always be a duration of one minute later. * This may cause the local date-time to change by an amount other than one minute. * Note that this is a different approach to that used by days, months and years. * <p> * This instance is immutable and unaffected by this method call. * * @param minutes the minutes to add, may be negative * @return a {@code ZonedDateTime} based on this date-time with the minutes added, not null * @throws DateTimeException if the result exceeds the supported date range */ public ZonedDateTime plusMinutes(long minutes) { return resolveInstant(dateTime.plusMinutes(minutes)); }
/** * Returns a copy of this {@code ZonedDateTime} with the specified period in nanoseconds added. * <p> * This operates on the instant time-line, such that adding one nano will * always be a duration of one nano later. * This may cause the local date-time to change by an amount other than one nano. * Note that this is a different approach to that used by days, months and years. * <p> * This instance is immutable and unaffected by this method call. * * @param nanos the nanos to add, may be negative * @return a {@code ZonedDateTime} based on this date-time with the nanoseconds added, not null * @throws DateTimeException if the result exceeds the supported date range */ public ZonedDateTime plusNanos(long nanos) { return resolveInstant(dateTime.plusNanos(nanos)); }
/** * Returns a copy of this {@code ZonedDateTime} with the specified period in seconds added. * <p> * This operates on the instant time-line, such that adding one second will * always be a duration of one second later. * This may cause the local date-time to change by an amount other than one second. * Note that this is a different approach to that used by days, months and years. * <p> * This instance is immutable and unaffected by this method call. * * @param seconds the seconds to add, may be negative * @return a {@code ZonedDateTime} based on this date-time with the seconds added, not null * @throws DateTimeException if the result exceeds the supported date range */ public ZonedDateTime plusSeconds(long seconds) { return resolveInstant(dateTime.plusSeconds(seconds)); }
/** * Returns a copy of this {@code ZonedDateTime} with the specified period in hours added. * <p> * This operates on the instant time-line, such that adding one hour will * always be a duration of one hour later. * This may cause the local date-time to change by an amount other than one hour. * Note that this is a different approach to that used by days, months and years, * thus adding one day is not the same as adding 24 hours. * <p> * For example, consider a time-zone where the spring DST cutover means that the * local times 01:00 to 01:59 occur twice changing from offset +02:00 to +01:00. * <p><ul> * <li>Adding one hour to 00:30+02:00 will result in 01:30+02:00 * <li>Adding one hour to 01:30+02:00 will result in 01:30+01:00 * <li>Adding one hour to 01:30+01:00 will result in 02:30+01:00 * <li>Adding three hours to 00:30+02:00 will result in 02:30+01:00 * </ul><p> * <p> * This instance is immutable and unaffected by this method call. * * @param hours the hours to add, may be negative * @return a {@code ZonedDateTime} based on this date-time with the hours added, not null * @throws DateTimeException if the result exceeds the supported date range */ public ZonedDateTime plusHours(long hours) { return resolveInstant(dateTime.plusHours(hours)); }
return resolveLocal(dateTime.plus(amountToAdd, unit)); } else { return resolveInstant(dateTime.plus(amountToAdd, unit));