当前位置:网站首页>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 2017see , 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
边栏推荐
- Current situation, trend and view of neural network Internet of things in the future
- Routing in laravel framework
- LeetCode_3(无重复字符的最长子串)
- Simple process of penetration test
- VC development of non MFC program memory leak tracking code
- After the microservice project is deployed, static resources and files uploaded to upload cannot be accessed. Solution
- Which Internet companies are worth going to in Shenzhen for software testers [Special Edition for software testers]
- C - Divisors of the Divisors of An Integer Gym - 102040C
- [buuctf.reverse] 152-154
- Discussion on memset assignment
猜你喜欢

TDengine 社区问题双周精选 | 第三期

How to deeply understand the design idea of "finite state machine"?

瑞能实业IPO被终止:年营收4.47亿 曾拟募资3.76亿
![UE source code reading [1]--- starting with problems delayed rendering in UE](/img/fa/f33242b01e4da973fa36c2c6f23db6.png)
UE source code reading [1]--- starting with problems delayed rendering in UE

Mingfeng medical sprint technology innovation board: annual revenue of 350million yuan, proposed to raise 624million yuan

Sqllab 1-6 exercise

What category does the Internet of things application technology major belong to

物联网应用技术专业是属于什么类

神经网络物联网未来现状和趋势及看法

upload (1-6)
随机推荐
2022 machine fitter (Advanced) test question simulation test question bank simulation test platform operation
PHP5下WSDL,SOAP调用实现过程
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
openGauss数据库源码解析系列文章—— 密态等值查询技术详解(下)
R語言ggplot2可視化:可視化折線圖、使用theme函數中的legend.position參數自定義圖例的比特置
[buuctf.reverse] 152-154
Leetcode array question brushing notes
Assembly language
鏈錶(簡單)
用“新”字来吸引好奇的人群
Liste des liens (simple)
Brief introduction to revolutionary neural networks
Deep copy is hard
非技术部门,如何参与 DevOps?
LeetCode_3(无重复字符的最长子串)
清大科越冲刺科创板:年营收2亿 拟募资7.5亿
Laravel dompdf exports PDF, and the problem of Chinese garbled code is solved
What are the advantages and characteristics of SAS interface
R language uses boxplot function in native package (basic import package, graphics) to visualize box plot
Enjoy what you want. Zhichuang future