package core.framework.impl.scheduler;

import core.framework.scheduler.Trigger;

import java.time.ZonedDateTime;

import static core.framework.util.Strings.format;

/**
 * @author keith
 */
public final class HourlyTrigger implements Trigger {
    private final int minute;
    private final int second;

    public HourlyTrigger(int minute, int second) {
        this.minute = minute;
        this.second = second;

        if (minute < 0 || minute > 59) {
            throw new Error(format("unsupported minute, please use 0-59, minute={}", minute));
        }
        if (second < 0 || second > 59) {
            throw new Error(format("unsupported second, please use 0-59, second={}", second));
        }
    }

    @Override
    public ZonedDateTime next(ZonedDateTime previous) {
        return previous.withMinute(minute).withSecond(second).withNano(0).plusHours(1);
    }

    @Override
    public String toString() {
        return format("hourly@{}:{}", minute, second);
    }
}

@@ -492,25 +492,26 @@
 at(%22
-unsupported minut
+minute out of rang
 e, p
@@ -639,26 +639,27 @@
 at(%22
-unsupported second
+second out of range
 , pl

edit error message