All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.mengweijin.quickboot.framework.util.CronDateUtil Maven / Gradle / Ivy

There is a newer version: 1.0.45
Show newest version
package com.github.mengweijin.quickboot.framework.util;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.apache.commons.lang3.time.DateUtils;

import java.text.ParseException;
import java.util.Date;

/**
 * @author Meng Wei Jin
 * @description
 **/
public class CronDateUtil {

    public static final String CRON = "ss mm HH dd MM ? yyyy";

    /**
     * 日期转cron表达式
     * @param date
     * @return
     */
    public static String formatCron(Date date){
        return DateFormatUtils.format(date, CRON);
    }

    /**
     * cron表达式转Date
     *
     * @return
     */
    public static Date parseCron(String cron) throws ParseException {
        return DateUtils.parseDate(cron, CronDateUtil.CRON);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy