[置顶] Quartz的DateBuilder详解

DateBuilder类有两个方法: nextGivenMinuteDate和nextGivenSecondDate;

Method: (a)  public static  Date   nextGivenMinuteDate ( Date  date ,  int minuteBase) ;
               (b) public static  Date   nextGivenSecondDate ( Date  date , int secondBase) ;
Note:Returns a date that is rounded to the next even multiple of the given minute/second.

API截图1:

详解:例如一个参数输入的日期为 08:13:54,另一个输入的基准时间间隔为5分钟,将会产生的结果是日期类型的时间:08:15:00;
这个是什么原因呢,看似没有任何规律,但是细心看下面更多的示例,就会发现:间隔是20分钟,不同的结果都是从11:00、11:20、11:40这样显示的,结果初始值都是00(分钟位),然后加上时间间隔;返回离初始时间最近的,比初始时间大的结果时间(在时间间隔范围内),如下图所示:
API截图2:


我的测试代码1:


测试结果1:


我的测试代码2:


我的测试结果2:




原文地址:https://www.cnblogs.com/javawebsoa/p/3237039.html