public static String createCronExpression(LocalDate siExcuteTime){
StringBuffer croExp=new StringBuffer();
sb.append("0 ");
//按日执行:每天15时执行:0 0 15 * * ? * 小时数可以根据自己需求更改
if(按日){
croExp.append("0 ");//分钟
croExp.append("15 ");//小时
croExp.append("* * ? *");
}
//按月执行:每月15号三点执行:0 0 3 15 * ? *
if(按月){
croExp.append("0 ");//分钟
croExp.append("3 ");//小时
croExp.append("15 * ? *");
}
//按年执行:每年6月1号5点执行:0 0 5 1 6 ? *
if(按年){
croExp.append("0 ");//分钟
croExp.append("5 ");//小时
croExp.append("1 6 ? *");
}
//按季度执行:7月18号开始每三个月执行一次:0 0 2 18 7,10,1,4 ? *
if(按季度){
//指定月份执行
int month1=7;
int month2=(month1+3)%12==0?12:(month1+3)%12;
int month3=(month2+3)%12==0?12:(month2+3)%12;
int month4=(month3+3)%12==0?12:(month3+3)%12;
croExp.append("0 ");//分钟
croExp.append("15 ");//小时
croExp.append("18 month1,month2,month3,month4 ? *");
quartz生成cron表达式工具类
最新推荐文章于 2025-05-20 13:30:35 发布