//string 转 cron格式
public static String formatDateByPattern(Date date,String dateFormat){
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
String formatTimeStr = null;
if (date != null) {
formatTimeStr = sdf.format(date);
}
return formatTimeStr;
}
public static String getCron(java.util.Date date){
String dateFormat="ss mm HH dd MM ?";
//String dateFormat="ss mm HH dd MM ? yyyy";
return formatDateByPattern(date, dateFormat);
}
将日期转为Cron表达式
最新推荐文章于 2024-07-28 16:13:47 发布