Refine search
/** * Rounds to the nearest whole unit of this field on a copy of this * LocalTime, favoring the floor if halfway. * * @return a copy of the LocalTime with the field value changed */ public LocalTime roundHalfFloorCopy() { return iInstant.withLocalMillis(iField.roundHalfFloor(iInstant.getLocalMillis())); }
/** * Returns a copy of this time with the partial set of fields replacing * those from this instance. * <p> * For example, if the partial contains an hour and minute then those two * fields will be changed in the returned instance. * Unsupported fields are ignored. * If the partial is null, then <code>this</code> is returned. * * @param partial the partial set of fields to apply to this time, null ignored * @return a copy of this time with a different set of fields * @throws IllegalArgumentException if any value is invalid */ public LocalTime withFields(ReadablePartial partial) { if (partial == null) { return this; } return withLocalMillis(getChronology().set(partial, getLocalMillis())); }
/** * Returns a copy of this time 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 #plusHours(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 time with the period added * @throws ArithmeticException if the result exceeds the internal capacity */ public LocalTime withPeriodAdded(ReadablePeriod period, int scalar) { if (period == null || scalar == 0) { return this; } long instant = getChronology().add(period, getLocalMillis(), scalar); return withLocalMillis(instant); }
/** * Adds to this field in a copy of this LocalTime. * <p> * The LocalTime 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 LocalTime with the field value changed */ public LocalTime addCopy(int value) { return iInstant.withLocalMillis(iField.add(iInstant.getLocalMillis(), value)); }
/** * Returns a copy of this time with the partial set of fields replacing * those from this instance. * <p> * For example, if the partial contains an hour and minute then those two * fields will be changed in the returned instance. * Unsupported fields are ignored. * If the partial is null, then <code>this</code> is returned. * * @param partial the partial set of fields to apply to this time, null ignored * @return a copy of this time with a different set of fields * @throws IllegalArgumentException if any value is invalid */ public LocalTime withFields(ReadablePartial partial) { if (partial == null) { return this; } return withLocalMillis(getChronology().set(partial, getLocalMillis())); }
/** * Sets this field in a copy of the LocalTime. * <p> * The LocalTime 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 LocalTime with the field value changed * @throws IllegalArgumentException if the value isn't valid */ public LocalTime setCopy(int value) { return iInstant.withLocalMillis(iField.set(iInstant.getLocalMillis(), value)); }
/** * Returns a copy of this time with the millis of day field updated. * <p> * LocalTime is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * millis of day changed. * * @param millis the millis of day to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid */ public LocalTime withMillisOfDay(int millis) { return withLocalMillis(getChronology().millisOfDay().set(getLocalMillis(), millis)); }
/** * Rounds to the nearest whole unit of this field on a copy of this * LocalTime, favoring the ceiling if halfway. * * @return a copy of the LocalTime with the field value changed */ public LocalTime roundHalfCeilingCopy() { return iInstant.withLocalMillis(iField.roundHalfCeiling(iInstant.getLocalMillis())); }
/** * Returns a copy of this time with the second of minute field updated. * <p> * LocalTime is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * second of minute changed. * * @param second the second of minute to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid */ public LocalTime withSecondOfMinute(int second) { return withLocalMillis(getChronology().secondOfMinute().set(getLocalMillis(), second)); }
/** * Rounds to the nearest whole unit of this field on a copy of this * LocalTime. If halfway, the ceiling is favored over the floor * only if it makes this field's value even. * * @return a copy of the LocalTime with the field value changed */ public LocalTime roundHalfEvenCopy() { return iInstant.withLocalMillis(iField.roundHalfEven(iInstant.getLocalMillis())); } }
/** * Returns a copy of this time with the hour of day field updated. * <p> * LocalTime 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 LocalTime withHourOfDay(int hour) { return withLocalMillis(getChronology().hourOfDay().set(getLocalMillis(), hour)); }
/** * Rounds to the highest whole unit of this field on a copy of this * LocalTime. * <p> * For example, rounding floor on the hourOfDay field of a LocalTime * where the time is 10:30 would result in new LocalTime with the * time of 11:00. * * @return a copy of the LocalTime with the field value changed */ public LocalTime roundCeilingCopy() { return iInstant.withLocalMillis(iField.roundCeiling(iInstant.getLocalMillis())); }
/** * Returns a copy of this time with the minute of hour field updated. * <p> * LocalTime 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 LocalTime withMinuteOfHour(int minute) { return withLocalMillis(getChronology().minuteOfHour().set(getLocalMillis(), minute)); }
/** * Adds to this field in a copy of this LocalTime. * <p> * The LocalTime 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 LocalTime with the field value changed */ public LocalTime addCopy(int value) { return iInstant.withLocalMillis(iField.add(iInstant.getLocalMillis(), value)); }
/** * Returns a copy of this time with the millis of second field updated. * <p> * LocalTime is immutable, so there are no set methods. * Instead, this method returns a new instance with the value of * millis of second changed. * * @param millis the millis of second to set * @return a copy of this object with the field set * @throws IllegalArgumentException if the value is invalid */ public LocalTime withMillisOfSecond(int millis) { return withLocalMillis(getChronology().millisOfSecond().set(getLocalMillis(), millis)); }
/** * Rounds to the nearest whole unit of this field on a copy of this * LocalTime, favoring the floor if halfway. * * @return a copy of the LocalTime with the field value changed */ public LocalTime roundHalfFloorCopy() { return iInstant.withLocalMillis(iField.roundHalfFloor(iInstant.getLocalMillis())); }
/** * Returns a copy of this time 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 #plusHours(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 time with the period added * @throws ArithmeticException if the result exceeds the internal capacity */ public LocalTime withPeriodAdded(ReadablePeriod period, int scalar) { if (period == null || scalar == 0) { return this; } long instant = getChronology().add(period, getLocalMillis(), scalar); return withLocalMillis(instant); }
/** * Rounds to the nearest whole unit of this field on a copy of this * LocalTime, favoring the ceiling if halfway. * * @return a copy of the LocalTime with the field value changed */ public LocalTime roundHalfCeilingCopy() { return iInstant.withLocalMillis(iField.roundHalfCeiling(iInstant.getLocalMillis())); }
/** * Returns a copy of this time with the hour of day field updated. * <p> * LocalTime 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 LocalTime withHourOfDay(int hour) { return withLocalMillis(getChronology().hourOfDay().set(getLocalMillis(), hour)); }
/** * Rounds to the nearest whole unit of this field on a copy of this * LocalTime. If halfway, the ceiling is favored over the floor * only if it makes this field's value even. * * @return a copy of the LocalTime with the field value changed */ public LocalTime roundHalfEvenCopy() { return iInstant.withLocalMillis(iField.roundHalfEven(iInstant.getLocalMillis())); } }