public List<TimeFrame> findFutureTimeFrames(Instant instant) {
   List<TimeFrame> futureTimeFrames = new ArrayList<TimeFrame>();
   for (TimeFrame timeFrame : timeFrames) {
     if (timeFrame.getInterval().getStart().isAfter(instant)) {
       futureTimeFrames.add(timeFrame);
     }
   }
   return futureTimeFrames;
 }
 public TimeFrame findCurrentTimeFrame(Instant instant) {
   if (timeFrames != null) {
     for (TimeFrame timeFrame : timeFrames) {
       if (timeFrame.getInterval().contains(instant)) {
         return timeFrame;
       }
     }
   }
   return null;
 }
 public void update() {
   Instant now = new Instant();
   TimeFrame timeFrameForInstant = findCurrentTimeFrame(now);
   if (timeFrameForInstant != null) {
     if (currentTimeFrame == null || !timeFrameForInstant.equals(currentTimeFrame)) {
       // timeframe changed
       currentTimeFrame = timeFrameForInstant;
       if (currentTimeFrame.getInterval().getStart().isBefore(now)) {
         // timeframe started in past; remaining time is less than MinRunningTime
         remainingMinRunningTime =
             Double.valueOf(
                     new Interval(now, currentTimeFrame.getInterval().getEnd()).toDurationMillis()
                         / 1000)
                 .longValue();
       } else {
         // timeframe starts in future
         remainingMinRunningTime = timeFrameForInstant.getMinRunningTime();
       }
     }
     Interval interval = null;
     if (running) {
       if (intervalBeginn == null) {
         // running was set to true after interval begin
         interval = new Interval(statusChangedAt, now);
       } else {
         // no status change in interval
         interval = new Interval(intervalBeginn, now);
       }
       intervalBeginn = now;
     } else if (intervalBeginn != null && statusChangedAt != null) {
       // running was set to false after interval begin
       interval = new Interval(intervalBeginn, statusChangedAt);
       intervalBeginn = null;
       statusChangedAt = null;
     }
     if (interval != null) {
       remainingMinRunningTime =
           remainingMinRunningTime
               - Double.valueOf(interval.toDuration().getMillis() / 1000).longValue();
     }
   }
 }