I am using java spring boot. I need to fetch data which updates as "Data sets are updated quarterly (March, June, September, December), typically on the first Friday of the month"
And I want to run Cron job on next Sunday (want to keep one entire saturday as buffer) after that. What will be Crone expression for this condition?
Reference for cron job. https://docs.oracle.com/cd/E12058_01/doc/doc.1014/e12030/cron_expressions.htm
Reference for spring boot cron job. https://www.tutorialspoint.com/spring_boot/spring_boot_scheduling.htm
Special cases we'll need to address: When Sunday is day #1 or day #2 of the month. By limiting Sundays to days in the range 3-9, we're safe. When Sunday is day #3 or greater, we can know for sure that there is a preceding Friday in current month.
Expression
Expression will fire at
Expression may be tested like this:
We can verify that the special-case is working as depicted by having a look into June 2024
From comment from OP
May 2021 is outside the quarterly schedule specified in question, but we can test this case by locking month to May and keep the rest of the expression unchanged like this:
Test code above will return
Sun, May 9, 2021 at 04:00:00 pmwhich is what OP is asking for.