当前位置:网站首页>Time to calculate cron expression based on cronsequencegenerator
Time to calculate cron expression based on cronsequencegenerator
2022-07-05 14:12:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
Spring Provides CronSequenceGenerator Class for calculation cron The specific time point of the expression next Method (Spring3.2 edition ) and cron Is it legal isValidExpression Method (Spring4.3 edition ).
Practical examples :
package construct;
import org.springframework.scheduling.support.CronSequenceGenerator;
import java.util.Date;
/**
* Created by zhangzh on 2017/1/18.
*/
public class CronSequenceGeneratorTest {
public static void main(String[] args) {
String cron = "0 */5 * * * ?"; // Every five minutes
CronSequenceGenerator cronSequenceGenerator = new CronSequenceGenerator(cron);
Date currentTime = new Date();
System.out.println("currentTime: " + currentTime);
Date nextTimePoint = cronSequenceGenerator.next(currentTime); // currentTime To calculate the start time of the next time point
System.out.println("nextTimePoint: " + nextTimePoint);
Date nextNextTimePoint = cronSequenceGenerator.next(nextTimePoint);
System.out.println("nextNextTimePoint: " + nextNextTimePoint);
}
}
Output results :
currentTime: Wed Jan 18 19:45:25 CST 2017
nextTimePoint: Wed Jan 18 19:50:00 CST 2017
nextNextTimePoint: Wed Jan 18 19:55:00 CST 2017
see , Easy !
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/149579.html Link to the original text :https://javaforall.cn
边栏推荐
- 2022 driller (drilling) examination question bank and simulation examination
- 怎么叫一手一机的功能方式
- Liste des liens (simple)
- Which Internet companies are worth going to in Shenzhen for software testers [Special Edition for software testers]
- Sqllab 1-6 exercise
- Geom of R language using ggplot2 package_ Histogram function visual histogram (histogram plot)
- UE source code reading [1]--- starting with problems delayed rendering in UE
- R语言使用MASS包的polr函数构建有序多分类logistic回归模型、使用coef函数获取模型中每个变量(自变量改变一个单位)对应的对数优势比(log odds ratio)
- Financial one account Hong Kong listed: market value of 6.3 billion HK $Ye wangchun said to be Keeping true and true, long - term work
- How to deeply understand the design idea of "finite state machine"?
猜你喜欢
TiFlash 源码解读(四) | TiFlash DDL 模块设计及实现分析
物联网应用技术专业是属于什么类
让秒杀狂欢更从容:大促背后的数据库(下篇)
如何深入理解“有限状态机”的设计思想?
Current situation, trend and view of neural network Internet of things in the future
Sqllab 1-6 exercise
基于 TiDB 场景式技术架构过程 - 理论篇
How to introduce devsecops into enterprises?
无密码身份验证如何保障用户隐私安全?
In addition to the root directory, other routes of laravel + xampp are 404 solutions
随机推荐
别不服气。手机功能升级就是强
R Language ggplot2 Visualization: visualize linegraph, using Legend in Theme function. Paramètre de position emplacement de la légende personnalisée
最长公共子序列 - 动态规划
最简单不用证书也可以多开功能的方式
TDengine 社区问题双周精选 | 第三期
Laravel dompdf exports PDF, and the problem of Chinese garbled code is solved
魅族新任董事長沈子瑜:創始人黃章先生將作為魅族科技產品戰略顧問
[machine learning notes] several methods of splitting data into training sets and test sets
登录界面代码
Blue Bridge Cup study 2022.7.5 (morning)
R语言dplyr包select函数、group_by函数、mutate函数、cumsum函数计算dataframe分组数据中指定数值变量的累加值、并生成累加数据列
[machine learning notes] how to solve over fitting and under fitting
C语言中限定符的作用
[js] basic syntax - for loop
04_solr7.3之solrJ7.3的使用
金融壹賬通香港上市:市值63億港元 葉望春稱守正篤實,久久為功
Request + BS4 crawl Netease cloud music popular comments
总量分析 核算方法和势方法 - 分摊分析
Introduction, installation, introduction and detailed introduction to postman!
动态规划