Cui Zhi Feng
2024-09-03 571a7d5b6321e0931b292bb33c0019f4264b2e78
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);
    }
}