⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 triggerutils.java

📁 Quartz is a full-featured, open source job scheduling system that can be integrated with, or used al
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    public static Trigger makeSecondlyTrigger(String trigName) {        return makeSecondlyTrigger(                trigName, 1, SimpleTrigger.REPEAT_INDEFINITELY);    }        /**     * <p>     * Make a trigger that will fire every N seconds, indefinitely.     * </p>     *      * <p>     * The generated trigger will not have its name, group,     * or end-time set.  The Start time defaults to 'now'.     * </p>     *      * @param intervalInSeconds the number of seconds between firings     * @return the new trigger     */    public static Trigger makeSecondlyTrigger(int intervalInSeconds) {        return makeSecondlyTrigger(                intervalInSeconds, SimpleTrigger.REPEAT_INDEFINITELY);    }    /**     * <p>     * Make a trigger that will fire every N seconds, with the given number of     * repeats.     * </p>     *      * <p>     * The generated trigger will not have its name, group,     * or end-time set.  The Start time defaults to 'now'.     * </p>     *      * @param intervalInSeconds the number of seconds between firings     * @param repeatCount the number of times to repeat the firing     * @return the new trigger     */    public static Trigger makeSecondlyTrigger(            int intervalInSeconds, int repeatCount) {        SimpleTrigger trig = new SimpleTrigger();        trig.setRepeatInterval(intervalInSeconds * 1000l);        trig.setRepeatCount(repeatCount);        trig.setStartTime(new Date());                 return trig;    }    /**     * <p>     * Make a trigger that will fire every N seconds, with the given number of     * repeats.     * </p>     *      * <p>     * The generated trigger will not have its group,     * or end-time set.  The Start time defaults to 'now'.     * </p>     *      * @param trigName the trigger's name     * @param intervalInSeconds the number of seconds between firings     * @param repeatCount the number of times to repeat the firing     * @return the new trigger     */    public static Trigger makeSecondlyTrigger(            String trigName, int intervalInSeconds, int repeatCount) {        Trigger trig = makeSecondlyTrigger(intervalInSeconds, repeatCount);        trig.setName(trigName);        return trig;    }    /**     * <p>     * Make a trigger that will fire every minute, indefinitely.     * </p>     *      * <p>     * The generated trigger will not have its name, group,     * or end-time set.  The Start time defaults to 'now'.     * </p>     *       * @return the new trigger     */    public static Trigger makeMinutelyTrigger() {        return makeMinutelyTrigger(1, SimpleTrigger.REPEAT_INDEFINITELY);    }    /**     * <p>     * Make a trigger that will fire every minute, indefinitely.     * </p>     *      * <p>     * The generated trigger will not have its group,     * or end-time set.  The Start time defaults to 'now'.     * </p>     *      * @param trigName the trigger's name      * @return the new trigger     */    public static Trigger makeMinutelyTrigger(String trigName) {        return makeMinutelyTrigger(                trigName, 1, SimpleTrigger.REPEAT_INDEFINITELY);    }        /**     * <p>     * Make a trigger that will fire every N minutes, indefinitely.     * </p>     *      * <p>     * The generated trigger will not have its name, group,     * or end-time set.  The Start time defaults to 'now'.     * </p>     *      * @param intervalInMinutes the number of minutes between firings     * @return the new trigger     */    public static Trigger makeMinutelyTrigger(int intervalInMinutes) {        return makeMinutelyTrigger(                intervalInMinutes, SimpleTrigger.REPEAT_INDEFINITELY);    }    /**     * <p>     * Make a trigger that will fire every N minutes, with the given number of     * repeats.     * </p>     *      * <p>     * The generated trigger will not have its name, group,     * or end-time set.  The Start time defaults to 'now'.     * </p>     *      * @param intervalInMinutes the number of minutes between firings     * @param repeatCount the number of times to repeat the firing     * @return the new trigger     */    public static Trigger makeMinutelyTrigger(            int intervalInMinutes, int repeatCount) {        SimpleTrigger trig = new SimpleTrigger();        trig.setRepeatInterval(intervalInMinutes * MILLISECONDS_IN_MINUTE);        trig.setRepeatCount(repeatCount);        trig.setStartTime(new Date());                return trig;    }    /**     * <p>     * Make a trigger that will fire every N minutes, with the given number of     * repeats.     * </p>     *      * <p>     * The generated trigger will not have its group,     * or end-time set.  The Start time defaults to 'now'.     * </p>     *      * @param trigName the trigger's name     * @param intervalInMinutes the number of minutes between firings     * @param repeatCount the number of times to repeat the firing     * @return the new trigger     */    public static Trigger makeMinutelyTrigger(            String trigName, int intervalInMinutes, int repeatCount) {        Trigger trig = makeMinutelyTrigger(intervalInMinutes, repeatCount);        trig.setName(trigName);        return trig;    }    /**     * <p>     * Make a trigger that will fire every hour, indefinitely.     * </p>     *      * <p>     * The generated trigger will not have its name, group,     * or end-time set.  The Start time defaults to 'now'.     * </p>     *       * @return the new trigger     */    public static Trigger makeHourlyTrigger() {        return makeHourlyTrigger(1, SimpleTrigger.REPEAT_INDEFINITELY);    }    /**     * <p>     * Make a trigger that will fire every hour, indefinitely.     * </p>     *      * <p>     * The generated trigger will not have its group,     * or end-time set.  The Start time defaults to 'now'.     * </p>     *      * @param trigName the trigger's name     * @return the new trigger     */    public static Trigger makeHourlyTrigger(String trigName) {        return makeHourlyTrigger(                trigName, 1, SimpleTrigger.REPEAT_INDEFINITELY);    }    /**     * <p>     * Make a trigger that will fire every N hours, indefinitely.     * </p>     *      * <p>     * The generated trigger will not have its name, group,     * or end-time set.  The Start time defaults to 'now'.     * </p>     *      * @param intervalInHours the number of hours between firings     * @return the new trigger     */    public static Trigger makeHourlyTrigger(int intervalInHours) {        return makeHourlyTrigger(                intervalInHours, SimpleTrigger.REPEAT_INDEFINITELY);    }    /**     * <p>     * Make a trigger that will fire every N hours, with the given number of     * repeats.     * </p>     *      * <p>     * The generated trigger will not have its name, group,     * or end-time set.  The Start time defaults to 'now'.     * </p>     *      * @param intervalInHours the number of hours between firings     * @param repeatCount the number of times to repeat the firing     * @return the new trigger     */    public static Trigger makeHourlyTrigger(            int intervalInHours, int repeatCount) {        SimpleTrigger trig = new SimpleTrigger();        trig.setRepeatInterval(intervalInHours * MILLISECONDS_IN_HOUR);        trig.setRepeatCount(repeatCount);        trig.setStartTime(new Date());                return trig;    }    /**     * <p>     * Make a trigger that will fire every N hours, with the given number of     * repeats.     * </p>     *      * <p>     * The generated trigger will not have its group,     * or end-time set.  The Start time defaults to 'now'.     * </p>     *      * @param trigName the trigger's name     * @param intervalInHours the number of hours between firings     * @param repeatCount the number of times to repeat the firing     * @return the new trigger     */    public static Trigger makeHourlyTrigger(            String trigName, int intervalInHours, int repeatCount) {        Trigger trig =makeHourlyTrigger(intervalInHours, repeatCount);        trig.setName(trigName);        return trig;    }    /**     * <p>     * Returns a date that is rounded to the next even hour above the given     * date.     * </p>     *      * <p>     * For example an input date with a time of 08:13:54 would result in a date     * with the time of 09:00:00. If the date's time is in the 23rd hour, the     * date's 'day' will be promoted, and the time will be set to 00:00:00.     * </p>     *      * @param date     *          the Date to round, if <code>null</code> the current time will     *          be used     * @return the new rounded date     */    public static Date getEvenHourDate(Date date) {        if (date == null) {            date = new Date();        }        Calendar c = Calendar.getInstance();        c.setTime(date);        c.setLenient(true);        c.set(Calendar.HOUR_OF_DAY, c.get(Calendar.HOUR_OF_DAY) + 1);        c.set(Calendar.MINUTE, 0);        c.set(Calendar.SECOND, 0);        c.set(Calendar.MILLISECOND, 0);        return c.getTime();    }    /**     * <p>     * Returns a date that is rounded to the previous even hour below the given     * date.     * </p>     *      * <p>     * For example an input date with a time of 08:13:54 would result in a date     * with the time of 08:00:00.     * </p>     *      * @param date     *          the Date to round, if <code>null</code> the current time will     *          be used     * @return the new rounded date     */    public static Date getEvenHourDateBefore(Date date) {        if (date == null) {            date = new Date();        }        Calendar c = Calendar.getInstance();        c.setTime(date);        c.set(Calendar.MINUTE, 0);        c.set(Calendar.SECOND, 0);        c.set(Calendar.MILLISECOND, 0);        return c.getTime();    }    /**     * <p>     * Returns a date that is rounded to the next even minute above the given     * date.     * </p>     *      * <p>     * For example an input date with a time of 08:13:54 would result in a date     * with the time of 08:14:00. If the date's time is in the 59th minute,     * then the hour (and possibly the day) will be promoted.     * </p>     *      * @param date     *          the Date to round, if <code>null</code> the current time will     *          be used     * @return the new rounded date     */    public static Date getEvenMinuteDate(Date date) {        if (date == null) {            date = new Date();        }        Calendar c = Calendar.getInstance();        c.setTime(date);        c.setLenient(true);        c.set(Calendar.MINUTE, c.get(Calendar.MINUTE) + 1);        c.set(Calendar.SECOND, 0);        c.set(Calendar.MILLISECOND, 0);        return c.getTime();    }    /**     * <p>     * Returns a date that is rounded to the previous even minute below the      * given date.     * </p>     *      * <p>     * For example an input date with a time of 08:13:54 would result in a date     * with the time of 08:13:00.     * </p>     *      * @param date     *          the Date to round, if <code>null</code> the current time will     *          be used     * @return the new rounded date     */    public static Date getEvenMinuteDateBefore(Date date) {        if (date == null) {            date = new Date();        }        Calendar c = Calendar.getInstance();        c.setTime(date);        c.set(Calendar.SECOND, 0);        c.set(Calendar.MILLISECOND, 0);        return c.getTime();    }    /**     * <p>     * Returns a date that is rounded to the next even second above the given     * date.     * </p>     *      * @param date     *          the Date to round, if <code>null</code> the current time will     *          be used     * @return the new rounded date     */    public static Date getEvenSecondDate(Date date) {        if (date == null) {            date = new Date();        }        Calendar c = Calendar.getInstance();        c.setTime(date);        c.setLenient(true);        c.set(Calendar.SECOND, c.get(Calendar.SECOND) + 1);        c.set(Calendar.MILLISECOND, 0);        return c.getTime();    }    /**     * <p>     * Returns a date that is rounded to the previous even second below the     * given date.     * </p>     *      * <p>     * For example an input date with a time of 08:13:54.341 would result in a     * date with the time of 08:13:00.000.     * </p>     *      * @param date     *          the Date to round, if <code>null</code> the current time will     *          be used     * @return the new rounded date     */    public static Date getEvenSecondDateBefore(Date date) {        if (date == null) {            date = new Date();        }        Calendar c = Calendar.getInstance();        c.setTime(date);        c.set(Calendar.MILLISECOND, 0);        return c.getTime();    }    /**     * <p>     * Returns a date that is rounded to the next even multiple of the given     * minute.     * </p>     *      * <p>     * For example an input date with a time of 08:13:54, and an input

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -