/** * Returns an adjusted copy of this time. * <p> * This returns a {@code LocalTime}, based on this one, with the time adjusted. * The adjustment takes place using the specified adjuster strategy object. * Read the documentation of the adjuster to understand what adjustment will be made. * <p> * A simple adjuster might simply set the one of the fields, such as the hour field. * A more complex adjuster might set the time to the last hour of the day. * <p> * The result of this method is obtained by invoking the * {@link TemporalAdjuster#adjustInto(Temporal)} method on the * specified adjuster passing {@code this} as the argument. * <p> * This instance is immutable and unaffected by this method call. * * @param TemporalAdjuster $adjuster the adjuster to use, not null * @return LocalTime a {@code LocalTime} based on {@code this} with the adjustment made, not null * @throws DateTimeException if the adjustment cannot be made * @throws ArithmeticException if numeric overflow occurs */ public function adjust(TemporalAdjuster $adjuster) { // optimizations if ($adjuster instanceof LocalTime) { return $adjuster; } return $adjuster->adjustInto($this); }
/** * Returns an adjusted copy of this instant. * <p> * This returns an Instant {@code Instant}, based on this one, with the instant adjusted. * The adjustment takes place using the specified adjuster strategy object. * Read the documentation of the adjuster to understand what adjustment will be made. * <p> * The result of this method is obtained by invoking the * {@link TemporalAdjuster#adjustInto(Temporal)} method on the * specified adjuster passing {@code this} as the argument. * <p> * This instance is immutable and unaffected by this method call. * * @param TemporalAdjuster $adjuster the adjuster to use, not null * @return Instant an Instant {@code Instant} based on {@code this} with the adjustment made, not null * @throws DateTimeException if the adjustment cannot be made * @throws ArithmeticException if numeric overflow occurs */ public function adjust(TemporalAdjuster $adjuster) { return $adjuster->adjustInto($this); }