Scheduler pattern with JAVA: how to check if current date time matches pattern
I'm wondering how to do some pattern matching in JAVA for date time. I have a database which has some开发者_运维知识库 entries that need to be scheduled.
Basically, I have a program that runs each 30 minutes. Inside this program (I own the code) I want to do a check against the database records on a field (non existent yet) if the current date / time matches the record's scheduler.
Examples of scheduler option should be something like: - daily + given hour - weekly + given hour - monthly + given hour - each Monday or Tuesday or Wednesday or ... at given hour
How should I store the scheduler pattern value (string, datetime, ?) and do the comparison inside my JAVA code to see if it matches?
Thanks
RFC 2445 should be useful to deal witch scheduling and recurrence. Here is a java library http://code.google.com/p/google-rfc-2445/.
You could store recurrence rules as a text in RRULE format, then parse it with the library to calculate the next recurrence date/time.
It should also be useful to change the app logic the other way around - to schedule execution at the specific calculated time, not to execute every 30 minutes trying to match the current time with recurrence patterns.
精彩评论