HourlyTrigger implements Trigger { @Override public ZonedDateTime next(ZonedDateTime previous) { ZonedDateTime next = previous.withMinute(minute).withSecond(second).withNano(0); if (!next.isAfter(previous)) { next = next.plusHours(1); } return next; } HourlyTrigger(int minute, int second); @Override ZonedDateTime next(ZonedDateTime previous); @Override String toString();  }
@Test void next() { var trigger = new HourlyTrigger(0, 0); assertThat(trigger.next(date("2019-08-16T09:00:00"))).isEqualTo(date("2019-08-16T10:00:00")); trigger = new HourlyTrigger(30, 0); assertThat(trigger.next(date("2019-08-16T09:30:00"))).isEqualTo(date("2019-08-16T10:30:00")); trigger = new HourlyTrigger(0, 30); assertThat(trigger.next(date("2019-08-16T09:00:20"))).isEqualTo(date("2019-08-16T09:00:30")); assertThat(trigger.next(date("2019-08-16T09:00:30"))).isEqualTo(date("2019-08-16T10:00:30")); }