0

How to write cron expressions for below?

  1. first working day of each month at 00:00:00
  2. 4th working day of each month at 06:00:00
  3. 00:00:00 on saturday

Based on above cron expression, how to get start date and end date?

  1. first day of prior month and first day of present month
  2. 1st of previous month and 3 rd working day of present month
  3. Date of monday on present week and date of staturday of present week.
Vikdor
  • 23,934
  • 10
  • 61
  • 84
user1726550
  • 83
  • 1
  • 4
  • 14

1 Answers1

2

Tested with Quartz scheduler:

first working day of each month at 00:00:00

 0 0 0 1W * ? *

4th working day of each month at 06:00:00

0 0 6 4W * ? *

00:00:00 on saturday

0 0 0 ? * SAT *
Tomasz Nurkiewicz
  • 334,321
  • 69
  • 703
  • 674
  • Thanks,How to calculate below in java .1.first day of prior month and first day of present month 2.1st of previous month and 3 rd working day of present month 3.Date of monday on present week and date of staturday of present week. – user1726550 Oct 20 '12 at 17:34
  • 0 0 6 4W * ? * : Returning 1970 as year. – user1726550 Oct 21 '12 at 11:40
  • How it will work when business day is Holiday?.How above cron expression works? – user1726550 Oct 21 '12 at 12:19
  • @user1726550: `W` is just a shorthand for week day (Mon - Fri), national holidays vary in every country and Quartz can't keep track of all of them. As for you other questions - try with simple `Calendar` class, it should help you a lot. Or better, go for Joda Time. – Tomasz Nurkiewicz Oct 21 '12 at 12:41
  • Thanks Tomasz,I am able to retrieve last month first and last date.But suppouse take eaxmle ,in one of the above cron expressions.job schedule at current month 4th working day.To give clear example ,in novemeber 2012 ,4th working day is november 5th.based on this i have to retrieve date.i.e november 4th.is it possible? – user1726550 Oct 21 '12 at 12:59
  • :Is it possible with Apache Quartz API. – user1726550 Oct 23 '12 at 18:47