Home > Mobile >  Is there something to represent a period like"first monday of every month" like cron?
Is there something to represent a period like"first monday of every month" like cron?

Time:10-12

I have an application where users can create repetitive tasks like "every 2 weeks" or "every first monday of month each month"

I tried to represent these period and compute the next execution time using CRON format but I searched and they can't be representated with CRON without more scripting.

I don't know if it is because I'm not english native and don't know proper keywords but I can't find an existing solution for this.

This "period" should be stored has a string and if possible, have existing js and java libraries to create it and generate the next datetime.

If nothing exist.. well, I'll create my own solution/format.

Thanks

CodePudding user response:

Like Thomas said, the format used by Quartz allows more use cases and works in the majority of mines. Thanks

http://www.quartz-scheduler.org/documentation/quartz-2.3.0/tutorials/crontrigger.html https://www.freeformatter.com/cron-expression-generator-quartz.html

CodePudding user response:

The first Monday of every month means:

  • Day of week = 1
  • Day of month = 1-7

Which as a cron expression is:

0 0 1-7 * 1
│ │  │  │ └─ Day of week 1 (Monday)
│ │  │  └─── Every month
│ │  └────── Day of month 1-7
│ └───────── Hour 0
└─────────── Minute 0

or the more readable:

0 0 1-7 * MON
  • Related