/** * 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)); }
/** * Get the month of year field value. * * @return the month of year */ public int getMonthOfYear() { return getChronology().monthOfYear().get(getLocalMillis()); }
/** * 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)); }
/** * 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())); }
/** * 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)); }
/** * Converts this object to a LocalTime with the same time and chronology. * * @return a LocalTime with the same time and chronology */ public LocalTime toLocalTime() { return new LocalTime(getLocalMillis(), getChronology()); }
/** * Returns a copy of this datetime with the year of century 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 century changed. * * @param yearOfCentury the year of century to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid */ public LocalDateTime withYearOfCentury(int yearOfCentury) { return withLocalMillis(getChronology().yearOfCentury().set(getLocalMillis(), yearOfCentury)); }
/** * Get the day of year field value. * * @return the day of year */ public int getDayOfYear() { return getChronology().dayOfYear().get(getLocalMillis()); }
/** * 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 month of year field updated. * <p> * LocalDateTime is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * month of year changed. * * @param monthOfYear the month of year to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid */ public LocalDateTime withMonthOfYear(int monthOfYear) { return withLocalMillis(getChronology().monthOfYear().set(getLocalMillis(), monthOfYear)); }
/** * Get the millis of second field value. * * @return the millis of second */ public int getMillisOfSecond() { return getChronology().millisOfSecond().get(getLocalMillis()); }
/** * 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)); }
/** * 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 hour of day field updated. * <p> * LocalDateTime is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * hour of day changed. * * @param hour the hour of day to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid */ public LocalDateTime withHourOfDay(int hour) { return withLocalMillis(getChronology().hourOfDay().set(getLocalMillis(), hour)); }
/** * Get the year of era field value. * * @return the year of era */ public int getYearOfEra() { return getChronology().yearOfEra().get(getLocalMillis()); }
/** * 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)); }