/** * Sets this field in a copy of the LocalDateTime. * <p> * The LocalDateTime attached to this property is unchanged by this call. * * @param value the value to set the field in the copy to * @return a copy of the LocalDateTime with the field value changed * @throws IllegalArgumentException if the value isn't valid */ public LocalDateTime setCopy(int value) { return iInstant.withLocalMillis(iField.set(iInstant.getLocalMillis(), value)); }
/** * Returns a copy of this datetime with the minute of hour field updated. * <p> * LocalDateTime is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * minute of hour changed. * * @param minute the minute of hour to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid */ public LocalDateTime withMinuteOfHour(int minute) { return withLocalMillis(getChronology().minuteOfHour().set(getLocalMillis(), minute)); }
/** * Adds to this field in a copy of this LocalDateTime. * <p> * The LocalDateTime attached to this property is unchanged by this call. * * @param value the value to add to the field in the copy * @return a copy of the LocalDateTime with the field value changed * @throws IllegalArgumentException if the value isn't valid */ public LocalDateTime addToCopy(int value) { return iInstant.withLocalMillis(iField.add(iInstant.getLocalMillis(), value)); }
/** * Returns a copy of this datetime with the partial set of fields * replacing those from this instance. * <p> * For example, if the partial is a <code>TimeOfDay</code> then the time fields * would be changed in the returned instance. * If the partial is null, then <code>this</code> is returned. * * @param partial the partial set of fields to apply to this datetime, null ignored * @return a copy of this datetime with a different set of fields * @throws IllegalArgumentException if any value is invalid */ public LocalDateTime withFields(ReadablePartial partial) { if (partial == null) { return this; } return withLocalMillis(getChronology().set(partial, getLocalMillis())); }
/** * Returns a copy of this datetime with the century of era field updated. * <p> * LocalDateTime is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * century of era changed. * * @param centuryOfEra the century of era to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid */ public LocalDateTime withCenturyOfEra(int centuryOfEra) { return withLocalMillis(getChronology().centuryOfEra().set(getLocalMillis(), centuryOfEra)); }
/** * Returns a copy of this datetime with the partial set of fields * replacing those from this instance. * <p> * For example, if the partial is a <code>TimeOfDay</code> then the time fields * would be changed in the returned instance. * If the partial is null, then <code>this</code> is returned. * * @param partial the partial set of fields to apply to this datetime, null ignored * @return a copy of this datetime with a different set of fields * @throws IllegalArgumentException if any value is invalid */ public LocalDateTime withFields(ReadablePartial partial) { if (partial == null) { return this; } return withLocalMillis(getChronology().set(partial, getLocalMillis())); }
/** * Sets this field in a copy of the LocalDateTime to a parsed text value. * <p> * The LocalDateTime attached to this property is unchanged by this call. * * @param text the text value to set * @param locale optional locale to use for selecting a text symbol * @return a copy of the LocalDateTime with the field value changed * @throws IllegalArgumentException if the text value isn't valid */ public LocalDateTime setCopy(String text, Locale locale) { return iInstant.withLocalMillis(iField.set(iInstant.getLocalMillis(), text, locale)); }
/** * Rounds to the nearest whole unit of this field on a copy of this * LocalDateTime, favoring the ceiling if halfway. * * @return a copy of the LocalDateTime with the field value changed */ public LocalDateTime roundHalfCeilingCopy() { return iInstant.withLocalMillis(iField.roundHalfCeiling(iInstant.getLocalMillis())); }
/** * Returns a copy of this datetime with the year of era field updated. * <p> * LocalDateTime is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * year of era changed. * * @param yearOfEra the year of era to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid */ public LocalDateTime withYearOfEra(int yearOfEra) { return withLocalMillis(getChronology().yearOfEra().set(getLocalMillis(), yearOfEra)); }
/** * Returns a copy of this datetime with the specified period added. * <p> * If the addition is zero, then <code>this</code> is returned. * <p> * This method is typically used to add multiple copies of complex * period instances. Adding one field is best achieved using methods * like {@link #withFieldAdded(DurationFieldType, int)} * or {@link #plusYears(int)}. * * @param period the period to add to this one, null means zero * @param scalar the amount of times to add, such as -1 to subtract once * @return a copy of this datetime with the period added * @throws ArithmeticException if the result exceeds the internal capacity */ public LocalDateTime withPeriodAdded(ReadablePeriod period, int scalar) { if (period == null || scalar == 0) { return this; } long instant = getChronology().add(period, getLocalMillis(), scalar); return withLocalMillis(instant); }
/** * Sets this field in a copy of the LocalDateTime. * <p> * The LocalDateTime attached to this property is unchanged by this call. * * @param value the value to set the field in the copy to * @return a copy of the LocalDateTime with the field value changed * @throws IllegalArgumentException if the value isn't valid */ public LocalDateTime setCopy(int value) { return iInstant.withLocalMillis(iField.set(iInstant.getLocalMillis(), value)); }
/** * Adds to this field in a copy of this LocalDateTime. * <p> * The LocalDateTime attached to this property is unchanged by this call. * * @param value the value to add to the field in the copy * @return a copy of the LocalDateTime with the field value changed * @throws IllegalArgumentException if the value isn't valid */ public LocalDateTime addToCopy(long value) { return iInstant.withLocalMillis(iField.add(iInstant.getLocalMillis(), value)); }
/** * Returns a copy of this datetime with the year field updated. * <p> * LocalDateTime is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * year changed. * * @param year the year to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid */ public LocalDateTime withYear(int year) { return withLocalMillis(getChronology().year().set(getLocalMillis(), year)); }
/** * Returns a copy of this datetime with the specified duration added. * <p> * If the addition is zero, then <code>this</code> is returned. * * @param durationToAdd the duration to add to this one, null means zero * @param scalar the amount of times to add, such as -1 to subtract once * @return a copy of this datetime with the duration added * @throws ArithmeticException if the result exceeds the internal capacity */ public LocalDateTime withDurationAdded(ReadableDuration durationToAdd, int scalar) { if (durationToAdd == null || scalar == 0) { return this; } long instant = getChronology().add(getLocalMillis(), durationToAdd.getMillis(), scalar); return withLocalMillis(instant); }
/** * Sets this field in a copy of the LocalDateTime to a parsed text value. * <p> * The LocalDateTime attached to this property is unchanged by this call. * * @param text the text value to set * @param locale optional locale to use for selecting a text symbol * @return a copy of the LocalDateTime with the field value changed * @throws IllegalArgumentException if the text value isn't valid */ public LocalDateTime setCopy(String text, Locale locale) { return iInstant.withLocalMillis(iField.set(iInstant.getLocalMillis(), text, locale)); }
/** * Rounds to the nearest whole unit of this field on a copy of this * LocalDateTime, favoring the floor if halfway. * * @return a copy of the LocalDateTime with the field value changed */ public LocalDateTime roundHalfFloorCopy() { return iInstant.withLocalMillis(iField.roundHalfFloor(iInstant.getLocalMillis())); }
/** * Returns a copy of this datetime with the day of week field updated. * <p> * LocalDateTime is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * day of week changed. * * @param dayOfWeek the day of week to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid */ public LocalDateTime withDayOfWeek(int dayOfWeek) { return withLocalMillis(getChronology().dayOfWeek().set(getLocalMillis(), dayOfWeek)); }
/** * Returns a copy of this datetime with the specified duration added. * <p> * If the addition is zero, then <code>this</code> is returned. * * @param durationToAdd the duration to add to this one, null means zero * @param scalar the amount of times to add, such as -1 to subtract once * @return a copy of this datetime with the duration added * @throws ArithmeticException if the result exceeds the internal capacity */ public LocalDateTime withDurationAdded(ReadableDuration durationToAdd, int scalar) { if (durationToAdd == null || scalar == 0) { return this; } long instant = getChronology().add(getLocalMillis(), durationToAdd.getMillis(), scalar); return withLocalMillis(instant); }
/** * Sets this field in a copy of the LocalDateTime. * <p> * The LocalDateTime attached to this property is unchanged by this call. * * @param value the value to set the field in the copy to * @return a copy of the LocalDateTime with the field value changed * @throws IllegalArgumentException if the value isn't valid */ public LocalDateTime setCopy(int value) { return iInstant.withLocalMillis(iField.set(iInstant.getLocalMillis(), value)); }
/** * Rounds to the nearest whole unit of this field on a copy of this * LocalDateTime. If halfway, the ceiling is favored over the floor * only if it makes this field's value even. * * @return a copy of the LocalDateTime with the field value changed */ public LocalDateTime roundHalfEvenCopy() { return iInstant.withLocalMillis(iField.roundHalfEven(iInstant.getLocalMillis())); } }