Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I think Spring has some classes to do this, if I remember correctly. Never used them though
-
Hazarth95092ySpring has Spring Cron, I only used their annotations, so I know for a fact they can parse it, but I never messed with the classes myself
and then there's Quartz Scheduler apparently. This seems to do exactly what you want using the CronExpression class and getNextValidTimeAfter(Date) function -
-
No, but what a coincidence, I've just started working on my Cron PR again
____
/____\
/ //ニヽ /ニヽ
||/⌒ヽ /⌒ L
i⌒ (●) (●) ヽ
ヽ_ |
>、___0_ノ
*Yes I know with 100+ million programmers it isn't that much of a coincidence.* -
@Hazarth I did the the SpringCron classes, but I'm not using Spring and I don't want to have the entire framework in there just to use the cron classes, I did look at the Quartz scheduler, but I didn't see the getNextValidTimeAfter method, so I'll probably take another look, thanks!
-
Hazarth95092y@daxinator22 I never used it myself. But here is a GitHub permalink to the method: https://github.com/quartz-scheduler...
You should theoretically be able to either just copy the entire class into your code (it seems to only be dependent on Java classes, so this should work out of the box I think?)
or you can try getting the library and see if you can find it there. The class is public and everything seems accessible to me. Good luck!
Related Rants
Does anybody know of a Java library that you can use to parse cron expressions? I mainly want to give it a cron expressions and have it calculate its next execution time.
question
cron
cronjob
java