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

📄 triggerutils.java

📁 Quartz is a full-featured, open source job scheduling system that can be integrated with, or used al
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     * <td>11:17:41</td>     * <td>1</td>     * <td>11:08:00</td>     * </tr>     * </table>     * </p>     *      * @param date     *          the Date to round, if <code>null</code> the current time will     *          be used     * @param minuteBase     *          the base-minute to set the time on     *      * @see #getNextGivenSecondDate(Date, int)     *      * @deprecated use org.quartz.TriggerUtils instead!     *      */    public static Date getNextGivenMinuteDate(Date date, int minuteBase) {        if (minuteBase < 0 || minuteBase > 59) {            throw new IllegalArgumentException(                    "minuteBase must be >=0 and <= 59");        }        if (date == null) {            date = new Date();        }        Calendar c = Calendar.getInstance();        c.setTime(date);        c.setLenient(true);        if (minuteBase == 0) {            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();        }        int minute = c.get(Calendar.MINUTE);        int arItr = minute / minuteBase;        int nextMinuteOccurance = minuteBase * (arItr + 1);        if (nextMinuteOccurance < 60) {            c.set(Calendar.MINUTE, nextMinuteOccurance);            c.set(Calendar.SECOND, 0);            c.set(Calendar.MILLISECOND, 0);            return c.getTime();        } else {            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 next even multiple of the given     * minute.     * </p>     *      * <p>     * The rules for calculating the second are the same as those for     * calculating the minute in the method <code>getNextGivenMinuteDate(..)<code>.</p>     *       *     * @param date the Date to round, if <code>null</code> the current time will     * be used     * @param secondBase the base-second to set the time on     *      * @see #getNextGivenMinuteDate(Date, int)     *      * @deprecated use org.quartz.TriggerUtils instead!     *      */    public static Date getNextGivenSecondDate(Date date, int secondBase) {        if (secondBase < 0 || secondBase > 59) {            throw new IllegalArgumentException(                    "secondBase must be >=0 and <= 59");        }        if (date == null) {            date = new Date();        }        Calendar c = Calendar.getInstance();        c.setTime(date);        c.setLenient(true);        if (secondBase == 0) {            c.set(Calendar.MINUTE, c.get(Calendar.MINUTE) + 1);            c.set(Calendar.SECOND, 0);            c.set(Calendar.MILLISECOND, 0);            return c.getTime();        }        int second = c.get(Calendar.SECOND);        int arItr = second / secondBase;        int nextSecondOccurance = secondBase * (arItr + 1);        if (nextSecondOccurance < 60) {            c.set(Calendar.SECOND, nextSecondOccurance);            c.set(Calendar.MILLISECOND, 0);            return c.getTime();        } else {            c.set(Calendar.MINUTE, c.get(Calendar.MINUTE) + 1);            c.set(Calendar.SECOND, 0);            c.set(Calendar.MILLISECOND, 0);            return c.getTime();        }    }    /**     * <p>     * Get a <code>Date</code> object that represents the given time, on     * today's date.     * </p>     *      * @param second     *          The value (0-59) to give the seconds field of the date     * @param minute     *          The value (0-59) to give the minutes field of the date     * @param hour     *          The value (0-23) to give the hours field of the date     *      * @deprecated use org.quartz.TriggerUtils instead!     *      */    public static Date getDateOf(int second, int minute, int hour) {        validateSecond(second);        validateMinute(minute);        validateHour(hour);        Date date = new Date();        Calendar c = Calendar.getInstance();        c.setTime(date);        c.setLenient(true);        c.set(Calendar.HOUR_OF_DAY, hour);        c.set(Calendar.MINUTE, minute);        c.set(Calendar.SECOND, second);        c.set(Calendar.MILLISECOND, 0);        return c.getTime();    }    /**     * <p>     * Get a <code>Date</code> object that represents the given time, on the     * given date.     * </p>     *      * @param second     *          The value (0-59) to give the seconds field of the date     * @param minute     *          The value (0-59) to give the minutes field of the date     * @param hour     *          The value (0-23) to give the hours field of the date     * @param dayOfMonth     *          The value (1-31) to give the day of month field of the date     * @param month     *          The value (1-12) to give the month field of the date     *      * @deprecated use org.quartz.TriggerUtils instead!     *      */    public static Date getDateOf(int second, int minute, int hour,            int dayOfMonth, int month) {        validateSecond(second);        validateMinute(minute);        validateHour(hour);        validateDayOfMonth(dayOfMonth);        validateMonth(month);        Date date = new Date();        Calendar c = Calendar.getInstance();        c.setTime(date);        c.set(Calendar.MONTH, month - 1);        c.set(Calendar.DAY_OF_MONTH, dayOfMonth);        c.set(Calendar.HOUR_OF_DAY, hour);        c.set(Calendar.MINUTE, minute);        c.set(Calendar.SECOND, second);        c.set(Calendar.MILLISECOND, 0);        return c.getTime();    }    /**     * <p>     * Get a <code>Date</code> object that represents the given time, on the     * given date.     * </p>     *      * @param second     *          The value (0-59) to give the seconds field of the date     * @param minute     *          The value (0-59) to give the minutes field of the date     * @param hour     *          The value (0-23) to give the hours field of the date     * @param dayOfMonth     *          The value (1-31) to give the day of month field of the date     * @param month     *          The value (1-12) to give the month field of the date     * @param year     *          The value (1970-2099) to give the year field of the date     *      * @deprecated use org.quartz.TriggerUtils instead!     *      */    public static Date getDateOf(int second, int minute, int hour,            int dayOfMonth, int month, int year) {        validateSecond(second);        validateMinute(minute);        validateHour(hour);        validateDayOfMonth(dayOfMonth);        validateMonth(month);        validateYear(year);        Date date = new Date();        Calendar c = Calendar.getInstance();        c.setTime(date);        c.set(Calendar.YEAR, year);        c.set(Calendar.MONTH, month - 1);        c.set(Calendar.DAY_OF_MONTH, dayOfMonth);        c.set(Calendar.HOUR_OF_DAY, hour);        c.set(Calendar.MINUTE, minute);        c.set(Calendar.SECOND, second);        c.set(Calendar.MILLISECOND, 0);        return c.getTime();    }    /**     * Returns a list of Dates that are the next fire times of a <code>Trigger</code>.     * The input trigger will be cloned before any work is done, so you need     * not worry about its state being altered by this method.     *      * @param trigg     *          The trigger upon which to do the work     * @param cal     *          The calendar to apply to the trigger's schedule     * @param numTimes     *          The number of next fire times to produce     * @return List of java.util.Date objects     *      * @deprecated use org.quartz.TriggerUtils instead!     *      */    public static List computeFireTimes(Trigger trigg, org.quartz.Calendar cal,            int numTimes) {        LinkedList lst = new LinkedList();        Trigger t = (Trigger) trigg.clone();        if (t.getNextFireTime() == null) {            t.computeFirstFireTime(cal);        }        for (int i = 0; i < numTimes; i++) {            Date d = t.getNextFireTime();            if (d != null) {                lst.add(d);                t.triggered(cal);            } else {                break;            }        }        return java.util.Collections.unmodifiableList(lst);    }    /**     * Returns a list of Dates that are the next fire times of a <code>Trigger</code>     * that fall within the given date range. The input trigger will be cloned     * before any work is done, so you need not worry about its state being     * altered by this method.     *      * @param trigg     *          The trigger upon which to do the work     * @param cal     *          The calendar to apply to the trigger's schedule     * @param from     *          The starting date at which to find fire times     * @param to     *          The ending date at which to stop finding fire times     * @return List of java.util.Date objects     *      * @deprecated use org.quartz.TriggerUtils instead!     *      *      */    public static List computeFireTimesBetween(Trigger trigg,            org.quartz.Calendar cal, Date from, Date to) {        LinkedList lst = new LinkedList();        Trigger t = (Trigger) trigg.clone();        if (t.getNextFireTime() == null) {            t.computeFirstFireTime(cal);        }        // TODO: this method could be more efficient by using logic specific        //        to the type of trigger ...        while (true) {            Date d = t.getNextFireTime();            if (d != null) {                if (d.before(from)) {                    t.triggered(cal);                    continue;                }                if (d.after(to)) {                    break;                }                lst.add(d);                t.triggered(cal);            } else {                break;            }        }        return java.util.Collections.unmodifiableList(lst);    }    /**     * Translate a date & time from a users timezone to the another     * (probably server) timezone to assist in creating a simple trigger with      * the right date & time.     *      * @deprecated use org.quartz.TriggerUtils instead!     */          public static Date translateTime(Date date, TimeZone src, TimeZone dest) {        Date newDate = new Date();        int offset = (getOffset(date.getTime(), dest) - getOffset(date.getTime(), src));        newDate.setTime(date.getTime() - offset);        return newDate;    }        /**     * Gets the offset from UT for the given date in the given timezone,      * taking into account daylight savings.     *      * <p>     * Equivalent of TimeZone.getOffset(date) in JDK 1.4, but Quartz is trying     * to support JDK 1.3.     * </p>     *      *      * @deprecated use org.quartz.TriggerUtils instead!     */    public static int getOffset(long date, TimeZone tz) {                if (tz.inDaylightTime(new Date(date))) {            return tz.getRawOffset() + getDSTSavings(tz);        }                return tz.getRawOffset();    }    /**     * <p>     * Equivalent of TimeZone.getDSTSavings() in JDK 1.4, but Quartz is trying     * to support JDK 1.3.     * </p>     *      * @deprecated use org.quartz.TriggerUtils instead!     */    public static int getDSTSavings(TimeZone tz) {                if (tz.useDaylightTime()) {            return 3600000;        }        return 0;    }    }

⌨️ 快捷键说明

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