陶杰
2024-11-27 f98f8be572e8701c7a3c5082a7087b8b44b22126
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);
    }
}