当前位置:网站首页>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
边栏推荐
- Getting started with rce
- 非技术部门,如何参与 DevOps?
- 享你所想。智创未来
- Postman简介、安装、入门使用方法详细攻略!
- Sqllab 1-6 exercise
- R语言ggplot2可视化条形图:通过双色渐变配色颜色主题可视化条形图、为每个条形添加标签文本(geom_text函数)
- 2022 machine fitter (Advanced) test question simulation test question bank simulation test platform operation
- C - Divisors of the Divisors of An Integer Gym - 102040C
- R语言使用ggplot2包的geom_histogram函数可视化直方图(histogram plot)
- 循环不变式
猜你喜欢
魅族新任董事长沈子瑜:创始人黄章先生将作为魅族科技产品战略顾问
Detailed explanation of IP address and preparation of DOS basic commands and batch processing
清大科越冲刺科创板:年营收2亿 拟募资7.5亿
Lepton 无损压缩原理及性能分析
Zhizhen new energy rushes to the scientific innovation board: the annual revenue is 220million, and SAIC venture capital is the shareholder
Make the seckill Carnival more leisurely: the database behind the promotion (Part 2)
物联网应用技术专业是属于什么类
LeetCode_2(两数相加)
Introduction, installation, introduction and detailed introduction to postman!
Deep copy is hard
随机推荐
为什么我认识的机械工程师都抱怨工资低?
一网打尽异步神器CompletableFuture
[machine learning notes] several methods of splitting data into training sets and test sets
2022 construction welder (special type of construction work) special operation certificate examination question bank and online simulation examination
What is the ranking of GF futures? Is it safe and reliable to open an account for GF futures online?
不相交集
poi设置列的数据格式(有效)
R language ggplot2 visual density map: Visual density map by group and custom configuration geom_ The alpha parameter in the density function sets the image transparency (to prevent multiple density c
PHP5下WSDL,SOAP调用实现过程
3W原则[通俗易懂]
Simple process of penetration test
04_solr7.3之solrJ7.3的使用
TiFlash 面向编译器的自动向量化加速
After the microservice project is deployed, static resources and files uploaded to upload cannot be accessed. Solution
无密码身份验证如何保障用户隐私安全?
非技术部门,如何参与 DevOps?
What category does the Internet of things application technology major belong to
金融壹账通香港上市:市值63亿港元 叶望春称守正笃实,久久为功
01 、Solr7.3.1 在Win10平台下使用jetty的部署及配置
Mysql database installation tutorial under Linux