This question already has answers here:
how to set cronjob for 2 days? [closed]
(3 answers)
Closed 9 years ago.
I need to create a cron expression that fires at a specific time every two days. So, for instance today is 26th of November. If I deploy my web app today and the scheduler should start the 28th the 30th the 2nd of december and so on...
Any help?
Thanks,
Luca
0 0 12 1/2 * ? *
Schedules
1. Wednesday, November 27, 2013 12:00 PM
2. Friday, November 29, 2013 12:00 PM
3. Sunday, December 1, 2013 12:00 PM
4. Tuesday, December 3, 2013 12:00 PM
5. Thursday, December 5, 2013 12:00 PM
For Ref: cronMaker
Quartz cookbook contains the How-To: Trigger That Executes Every 2 Days
Related
I want to get valid dates between certain dates via cron expression. Is this possible?
Returns only 1 with getNextValidTimeAfter.
For example, my statement is as follows;
0 0 0? MAY, JUN, JUL MON, TUE 2020-2024
This means:
At 00:00:00 am, on every Monday and Tuesday, in May, June and July, between 2020 and 2024
What I want to do is;
To bring the days in this statement between June 2020 and September 2020.
Months are entered as numbers so it should be something like this: 0 0 0 ? 5-9 * 2020-2024. Look at this resource for more information.
What will the best strategy to match date and time of two persons timings. Like one person is free from
15th june 2015 9:00 to 05: PM
16th june 2015 10:00 to 06: PM
17th june 2015 9:00 to 05: PM
and second person free timings are
15th june 2015 8:00 to 04:00 PM
16th june 2015 10:00 to 06:00 PM
17th june 2015 9:00 to 02:00 PM
how to save them in jdo at google app engine datastore so that it will take less time and read operations to query. currently i am using a method which is taking approx 1,500 read operations for one query. please help.
my jdo structure is
private String id;
private String name;
private userKey; (Foreign key from user table.)
private String designation;
private Set<Long> timing; // it has timing for 15 min interval [201506150800, 201506150815, 201506150830...]
while query i have to find which employee has overlapping timing with my timing. Like i am free from 7:00 9:00 on 15th June 2015 so i can book appointment with one of them.
i have a job to be run on the last weekend of the month (i.e) if the month has a sunday at the end it should run on sunday and if the month ends or has a saturday at the end the job should run on saturday.
I didnt find any documentation to build a cron expression for this case.
Thanks in advance.
You can use L in the day of week field
0 0 0 ? * SUNL
This will trigger at every last SUN of every month, e.g.
Sunday, August 31, 2014 12:00 AM
Sunday, September 28, 2014 12:00 AM
Sunday, October 26, 2014 12:00 AM
Sunday, November 30, 2014 12:00 AM
Sunday, December 28, 2014 12:00 AM
I don't see a way to specify the last weekend of a month since quartz does not allow to combine the L character with multiple days of week. So you can't do something like SATL,SUNL. If you want to trigger something on every last SAT and SUN I would define 2 cron expressions.
From the quartz documentation (Special characters)
L ("last") - .....
for example "6L" means "the last friday of the month".
I tested it with my cron expression view - a plugin that I wrote for eclipse
https://github.com/link-intersystems/eclipse-plugins-repository. Maybe it is also useful for you,
I'm using the library DateTime to store date values for birthdays.
DateTime dateTime01Abegin = new DateTime(2013, 5, 23, 00, 00);
DateTime dateTime01Bbegin = new DateTime(2012, 5, 22, 00, 00);
Running the method .getDayOfYear() on them, I am getting a value of 143 for both. But one is May 23rd and one is May 22nd - I can't figure why they're returning the same value!
2012 has 366 (february 29) days and 2013 has 365, that's why both dates return 143.
The count of the days in a year has an offset of one day in leap years, since after february 28 leap years have an additional day compared to normal ones.
Not every year is 365 days long, some years are 366 days long.
2012 is a leap year, which means that it has an additional day, February 29th. For dates prior to February 28th, the .getDayOfYear() will return the same values for similar dates for any year. For dates after February 28th, .getDayOfYear() will return the same values for similar dates if both of those dates are in a leap year, or if both of those dates are not in a leap year. Otherwise, they should be off by one.
Leapyears. 2012 is a leapyear, so there was a Feb 29th, pushing all the "later" dates up one slot, so your May 22nd is actually day 143 in both years.
2012 was a leap year. So may 23 2013 came 1 day before may 23 2012.
Consider the following code is run in GWT:
import com.google.gwt.i18n.client.DateTimeFormat;
...
DateTimeFormat fullDateTimeFormat = DateTimeFormat.getFullDateTimeFormat();
Log.info(fullDateTimeFormat.format(date, TimeZone.createTimeZone(-120)));
Log.info(fullDateTimeFormat.format(date, TimeZone.createTimeZone(0)));
Log.info(fullDateTimeFormat.format(date, TimeZone.createTimeZone(180)));
And supposing it is Greenwich time 16:00.
Why do I get the following output?
Monday, February 21, 2011 6:00:00 PM Etc/GMT-2
Monday, February 21, 2011 4:00:00 PM Etc/GMT
Monday, February 21, 2011 1:00:00 PM Etc/GMT+3
The expected one is
Monday, February 21, 2011 2:00:00 PM Etc/GMT-2
Monday, February 21, 2011 4:00:00 PM Etc/GMT
Monday, February 21, 2011 7:00:00 PM Etc/GMT+3
What is the right way to fix it?
"Etc/GMT-2" is actually (and very surprisingly) "+02:00", see http://en.wikipedia.org/wiki/Tz_database#Area:
In order to conform with the POSIX style, those zones beginning with "Etc/GMT" have their sign reversed from what most people expect. In this style, zones west of GMT have a positive sign and those east have a negative sign.
Your code leads to a different output on my machine (probably because of my different Locale):
Monday, 2011 February 21 18:00:00 UTC+2
Monday, 2011 February 21 16:00:00 UTC
Monday, 2011 February 21 13:00:00 UTC-3
So, it's not DateTimeFormat which is responsible for the reversing, but TimeZone.createTimeZone(int timeZoneOffsetInMinutes)!
Let's look a bit more into the GWT javadocs of com.google.gwt.i18n.client.TimeZone:
getOffset(Date date):
* Returns the RFC representation of the time zone name for the given date.
* To be consistent with JDK/Javascript API, west of Greenwich will be
* positive.
and composeGMTString(int offset):
* In GMT representation, +/- has reverse sign of time zone offset.
* when offset == 480, it should output GMT-08:00.
I had a look at the source code. It has comments saying
20:00 GMT0000, or 16:00 GMT-0400, or 12:00 GMT-0800
are all the same. As per that I infer the relation between time and timezone as the amount of time subtracted from GMT or added to the GMT. So 16.00 GMT becomes 1400 GMT -0200 or 1900 GMT +0300. Keeping that in mind we have to work the other way around to get the desired result.