/** * Returns a copy of this {@code LocalDateTime} with the nano-of-second value altered. * <p> * This instance is immutable and unaffected by this method call. * * @param nanoOfSecond the nano-of-second to set in the result, from 0 to 999,999,999 * @return a {@code LocalDateTime} based on this date-time with the requested nanosecond, not null * @throws DateTimeException if the nano value is invalid */ public LocalDateTime withNano(int nanoOfSecond) { LocalTime newTime = time.withNano(nanoOfSecond); return with(date, newTime); }
/** * Returns a copy of this {@code LocalDateTime} with the minute-of-hour value altered. * <p> * This instance is immutable and unaffected by this method call. * * @param minute the minute-of-hour to set in the result, from 0 to 59 * @return a {@code LocalDateTime} based on this date-time with the requested minute, not null * @throws DateTimeException if the minute value is invalid */ public LocalDateTime withMinute(int minute) { LocalTime newTime = time.withMinute(minute); return with(date, newTime); }
/** * Returns a copy of this {@code LocalDateTime} with the second-of-minute value altered. * <p> * This instance is immutable and unaffected by this method call. * * @param second the second-of-minute to set in the result, from 0 to 59 * @return a {@code LocalDateTime} based on this date-time with the requested second, not null * @throws DateTimeException if the second value is invalid */ public LocalDateTime withSecond(int second) { LocalTime newTime = time.withSecond(second); return with(date, newTime); }
/** * Returns a copy of this {@code LocalDateTime} with the hour-of-day value altered. * <p> * This instance is immutable and unaffected by this method call. * * @param hour the hour-of-day to set in the result, from 0 to 23 * @return a {@code LocalDateTime} based on this date-time with the requested hour, not null * @throws DateTimeException if the hour value is invalid */ public LocalDateTime withHour(int hour) { LocalTime newTime = time.withHour(hour); return with(date, newTime); }
/** * Returns a copy of this {@code LocalDateTime} with the minute-of-hour value altered. * <p> * This instance is immutable and unaffected by this method call. * * @param minute the minute-of-hour to set in the result, from 0 to 59 * @return a {@code LocalDateTime} based on this date-time with the requested minute, not null * @throws DateTimeException if the minute value is invalid */ public LocalDateTime withMinute(int minute) { LocalTime newTime = time.withMinute(minute); return with(date, newTime); }
/** * Returns a copy of this {@code LocalDateTime} with the nano-of-second value altered. * <p> * This instance is immutable and unaffected by this method call. * * @param nanoOfSecond the nano-of-second to set in the result, from 0 to 999,999,999 * @return a {@code LocalDateTime} based on this date-time with the requested nanosecond, not null * @throws DateTimeException if the nano value is invalid */ public LocalDateTime withNano(int nanoOfSecond) { LocalTime newTime = time.withNano(nanoOfSecond); return with(date, newTime); }
/** * Returns a copy of this {@code LocalDateTime} with the hour-of-day value altered. * <p> * This instance is immutable and unaffected by this method call. * * @param hour the hour-of-day to set in the result, from 0 to 23 * @return a {@code LocalDateTime} based on this date-time with the requested hour, not null * @throws DateTimeException if the hour value is invalid */ public LocalDateTime withHour(int hour) { LocalTime newTime = time.withHour(hour); return with(date, newTime); }
/** * Returns a copy of this {@code LocalDateTime} with the second-of-minute value altered. * <p> * This instance is immutable and unaffected by this method call. * * @param second the second-of-minute to set in the result, from 0 to 59 * @return a {@code LocalDateTime} based on this date-time with the requested second, not null * @throws DateTimeException if the second value is invalid */ public LocalDateTime withSecond(int second) { LocalTime newTime = time.withSecond(second); return with(date, newTime); }
/** * Returns a copy of this {@code LocalDateTime} with the year altered. * The time does not affect the calculation and will be the same in the result. * If the day-of-month is invalid for the year, it will be changed to the last valid day of the month. * <p> * This instance is immutable and unaffected by this method call. * * @param year the year to set in the result, from MIN_YEAR to MAX_YEAR * @return a {@code LocalDateTime} based on this date-time with the requested year, not null * @throws DateTimeException if the year value is invalid */ public LocalDateTime withYear(int year) { return with(date.withYear(year), time); }
/** * Returns a copy of this {@code LocalDateTime} with the month-of-year altered. * The time does not affect the calculation and will be the same in the result. * If the day-of-month is invalid for the year, it will be changed to the last valid day of the month. * <p> * This instance is immutable and unaffected by this method call. * * @param month the month-of-year to set in the result, from 1 (January) to 12 (December) * @return a {@code LocalDateTime} based on this date-time with the requested month, not null * @throws DateTimeException if the month-of-year value is invalid */ public LocalDateTime withMonth(int month) { return with(date.withMonth(month), time); }
/** * Returns a copy of this {@code LocalDateTime} with the day-of-year altered. * If the resulting {@code LocalDateTime} is invalid, an exception is thrown. * <p> * This instance is immutable and unaffected by this method call. * * @param dayOfYear the day-of-year to set in the result, from 1 to 365-366 * @return a {@code LocalDateTime} based on this date with the requested day, not null * @throws DateTimeException if the day-of-year value is invalid * @throws DateTimeException if the day-of-year is invalid for the year */ public LocalDateTime withDayOfYear(int dayOfYear) { return with(date.withDayOfYear(dayOfYear), time); }
/** * Returns a copy of this {@code LocalDateTime} with the day-of-year altered. * If the resulting {@code LocalDateTime} is invalid, an exception is thrown. * <p> * This instance is immutable and unaffected by this method call. * * @param dayOfYear the day-of-year to set in the result, from 1 to 365-366 * @return a {@code LocalDateTime} based on this date with the requested day, not null * @throws DateTimeException if the day-of-year value is invalid * @throws DateTimeException if the day-of-year is invalid for the year */ public LocalDateTime withDayOfYear(int dayOfYear) { return with(date.withDayOfYear(dayOfYear), time); }
/** * Returns a copy of this {@code LocalDateTime} with the year altered. * The time does not affect the calculation and will be the same in the result. * If the day-of-month is invalid for the year, it will be changed to the last valid day of the month. * <p> * This instance is immutable and unaffected by this method call. * * @param year the year to set in the result, from MIN_YEAR to MAX_YEAR * @return a {@code LocalDateTime} based on this date-time with the requested year, not null * @throws DateTimeException if the year value is invalid */ public LocalDateTime withYear(int year) { return with(date.withYear(year), time); }
/** * Returns a copy of this {@code LocalDateTime} with the month-of-year altered. * The time does not affect the calculation and will be the same in the result. * If the day-of-month is invalid for the year, it will be changed to the last valid day of the month. * <p> * This instance is immutable and unaffected by this method call. * * @param month the month-of-year to set in the result, from 1 (January) to 12 (December) * @return a {@code LocalDateTime} based on this date-time with the requested month, not null * @throws DateTimeException if the month-of-year value is invalid */ public LocalDateTime withMonth(int month) { return with(date.withMonth(month), time); }
/** * Returns a copy of this {@code LocalDateTime} with the day-of-month altered. * If the resulting {@code LocalDateTime} is invalid, an exception is thrown. * The time does not affect the calculation and will be the same in the result. * <p> * This instance is immutable and unaffected by this method call. * * @param dayOfMonth the day-of-month to set in the result, from 1 to 28-31 * @return a {@code LocalDateTime} based on this date-time with the requested day, not null * @throws DateTimeException if the day-of-month value is invalid * @throws DateTimeException if the day-of-month is invalid for the month-year */ public LocalDateTime withDayOfMonth(int dayOfMonth) { return with(date.withDayOfMonth(dayOfMonth), time); }
/** * Returns a copy of this {@code LocalDateTime} with the day-of-month altered. * If the resulting {@code LocalDateTime} is invalid, an exception is thrown. * The time does not affect the calculation and will be the same in the result. * <p> * This instance is immutable and unaffected by this method call. * * @param dayOfMonth the day-of-month to set in the result, from 1 to 28-31 * @return a {@code LocalDateTime} based on this date-time with the requested day, not null * @throws DateTimeException if the day-of-month value is invalid * @throws DateTimeException if the day-of-month is invalid for the month-year */ public LocalDateTime withDayOfMonth(int dayOfMonth) { return with(date.withDayOfMonth(dayOfMonth), time); }
/** * Returns a copy of this {@code LocalDateTime} with the specified period in days added. * <p> * This method adds the specified amount to the days field incrementing the * month and year fields as necessary to ensure the result remains valid. * The result is only invalid if the maximum/minimum year is exceeded. * <p> * For example, 2008-12-31 plus one day would result in 2009-01-01. * <p> * This instance is immutable and unaffected by this method call. * * @param days the days to add, may be negative * @return a {@code LocalDateTime} based on this date-time with the days added, not null * @throws DateTimeException if the result exceeds the supported date range */ public LocalDateTime plusDays(long days) { LocalDate newDate = date.plusDays(days); return with(newDate, time); }
/** * Returns a copy of this {@code LocalDateTime} with the specified period in weeks added. * <p> * This method adds the specified amount in weeks to the days field incrementing * the month and year fields as necessary to ensure the result remains valid. * The result is only invalid if the maximum/minimum year is exceeded. * <p> * For example, 2008-12-31 plus one week would result in 2009-01-07. * <p> * This instance is immutable and unaffected by this method call. * * @param weeks the weeks to add, may be negative * @return a {@code LocalDateTime} based on this date-time with the weeks added, not null * @throws DateTimeException if the result exceeds the supported date range */ public LocalDateTime plusWeeks(long weeks) { LocalDate newDate = date.plusWeeks(weeks); return with(newDate, time); }
/** * Returns a copy of this {@code LocalDateTime} with the specified period in days added. * <p> * This method adds the specified amount to the days field incrementing the * month and year fields as necessary to ensure the result remains valid. * The result is only invalid if the maximum/minimum year is exceeded. * <p> * For example, 2008-12-31 plus one day would result in 2009-01-01. * <p> * This instance is immutable and unaffected by this method call. * * @param days the days to add, may be negative * @return a {@code LocalDateTime} based on this date-time with the days added, not null * @throws DateTimeException if the result exceeds the supported date range */ public LocalDateTime plusDays(long days) { LocalDate newDate = date.plusDays(days); return with(newDate, time); }
/** * Returns a copy of this {@code LocalDateTime} with the specified period in weeks added. * <p> * This method adds the specified amount in weeks to the days field incrementing * the month and year fields as necessary to ensure the result remains valid. * The result is only invalid if the maximum/minimum year is exceeded. * <p> * For example, 2008-12-31 plus one week would result in 2009-01-07. * <p> * This instance is immutable and unaffected by this method call. * * @param weeks the weeks to add, may be negative * @return a {@code LocalDateTime} based on this date-time with the weeks added, not null * @throws DateTimeException if the result exceeds the supported date range */ public LocalDateTime plusWeeks(long weeks) { LocalDate newDate = date.plusWeeks(weeks); return with(newDate, time); }