Em convert cron sang ngày, thì ngày convert ra cách ngày hiện tại 1 tuần
Cron: 0 23 16 ? * THU
– 2023/01/19 16:23:00
– 2023/01/12 16:28:00
Làm cách nào để lấy được ngày giờ hiện tại của cron vậy ạ
Code
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd HH:mm:00"); LOGGER.info("Cron: " + emailConfig.getTimeSendMail()); CronExpression cronExpression = CronExpression.parse("0 23 16 ? * THU"); LocalDateTime nextRunDate = cronExpression.next(LocalDateTime.now()); LOGGER.info(dtf.format(nextRunDate)); LocalDateTime current = LocalDateTime.now(); LOGGER.info(dtf.format(current));
Ý em là ngày giờ hiện tại mà cron đang chạy à, hay sao em nhỉ? Anh chưa hiểu ý câu hỏi vì cron nó là 1 biểu thức chứ không có hiện tại hay tương lai giờ ở đây cả.