gongzuming
2024-09-03 0a9e89a052663fbaee67e59f7b070ad6b110df44
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package com.mzl.flower.utils;
 
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
 
public class CronExpressionUtil {
    /**
     * convert Date to cron ,eg.  "0 06 10 15 1 ? 2014"
     * @param date  : 时间点
     * @return
     */
    public static String getCron(ZonedDateTime date){
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("ss mm HH dd MM ? yyyy").withZone(ZoneId.of("Asia/Shanghai"));
        return dateTimeFormatter.format(date);
    }
}