code: public final void changeEndTime(LocalTime time, boolean keepDuration) {
          requireNonNull(time);
  
          Interval interval = getInterval();
  
          LocalDateTime newEndDateTime = getEndAsLocalDateTime().with(time);
          LocalDateTime startDateTime = getStartAsLocalDateTime();
  
          if (keepDuration) {
              startDateTime = newEndDateTime.minus(getDuration());
              setInterval(startDateTime, newEndDateTime, getZoneId());
          } else {
              /*
               * We might have a problem if the new end time is BEFORE the current start time.
               */
              if (newEndDateTime.isBefore(startDateTime.plus(getMinimumDuration()))) {
                  interval = interval.withStartDateTime(newEndDateTime.minus(getMinimumDuration()));
              }
  
              setInterval(interval.withEndTime(time));
          }
      }
docs: Changes the end time of the entry interval.
  
  @param time         the new end time
  @param keepDuration if true then this method will also change the start time in such a way that the total duration
  of the entry will not change. If false then this method will ensure that the entry's interval
  stays valid, which means that the start time will be before the end time and that the
  duration of the entry will be at least the duration defined by the {@link #minimumDurationProperty()}.