Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8871031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:52:44+00:00 2026-06-14T17:52:44+00:00

I have a problem using a HolidayCalendar. It seems that the calendar is simply

  • 0

I have a problem using a HolidayCalendar. It seems that the calendar is simply ignored.

Here my code (which mostly repeats code snippets from Quartz documentation):

public class Cron {


    public static void main(String[] args) {

        try {
            Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();

            Calendar cbegin = Calendar.getInstance(), cend = Calendar.getInstance();
            cbegin.set(Calendar.MONTH, Calendar.NOVEMBER);
            cend.set(Calendar.MONTH, Calendar.NOVEMBER);

            // exclude Nov 23 and Nov 24
            HolidayCalendar cln = new HolidayCalendar();

            cbegin.set(Calendar.DAY_OF_MONTH, 23);
            cln.addExcludedDate(new Date(cbegin.getTimeInMillis()));
            cbegin.set(Calendar.DAY_OF_MONTH, 24);
            cln.addExcludedDate(new Date(cbegin.getTimeInMillis()));

            scheduler.addCalendar("job1", cln, false, false);

            JobDetail job = newJob(HelloJob.class).withIdentity("job1").build();

            // trigger running once a day at 1 AM
            Trigger trigger = newTrigger().withIdentity("trigger10").forJob(job)
                .withSchedule(cronSchedule("0 0 1 * * ?"))
                .modifiedByCalendar("job1")
                .build();

            scheduler.scheduleJob(job, trigger);
            scheduler.start();

            // print fired times from Nov 21 to Nov 30
            cbegin.set(Calendar.DAY_OF_MONTH, 21);
            cend.set(Calendar.DAY_OF_MONTH, 30);

            Date dtnext = new Date(cbegin.getTimeInMillis()), dtend = new Date(cend.getTimeInMillis());
            do { 
                dtnext = trigger.getFireTimeAfter(dtnext); 
                System.out.println("Next... " + dtnext);
            } while(dtnext.before(dtend)); 

            try { Thread.sleep(3600000); } catch(InterruptedException ie) {}

            scheduler.shutdown();

        } catch (Exception se) {
            se.printStackTrace();
        }
    }
}

And the results are:

 [java] Next... Thu Nov 22 01:00:00 CET 2012
 [java] Next... Fri Nov 23 01:00:00 CET 2012
 [java] Next... Sat Nov 24 01:00:00 CET 2012
 [java] Next... Sun Nov 25 01:00:00 CET 2012
 [java] Next... Mon Nov 26 01:00:00 CET 2012
 [java] Next... Tue Nov 27 01:00:00 CET 2012
 [java] Next... Wed Nov 28 01:00:00 CET 2012
 [java] Next... Thu Nov 29 01:00:00 CET 2012
 [java] Next... Fri Nov 30 01:00:00 CET 2012
 [java] Next... Sat Dec 01 01:00:00 CET 2012

As you can see, excluded dates Nov 23 and Nov 24 are still scheduled.

What is wrong in my code?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:52:46+00:00Added an answer on June 14, 2026 at 5:52 pm

    Actually, the job won’t be executed.

    I modified a trigger to launch the job every minute and it’s not executed on the excluded dates. But trigger.getFireTimeAfter still returns fired time on excluded date.

    To solve a problem I need to check manually if the fired time is included in the calendar.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem using JSON and arrays. Here is my code: while($row =
I have a problem using QBE with NHibernate. Here's a sample code: Person person
I have a problem using fadeIn() on div that contains elements which positions are
I have problem in using Persist() method of EntityManager which return NullPointerExpception , here
i have a problem using the Catch Clipboard Events code found on this link
I have a problem using first-child I have the following html code to make
I have a problem using AJAX. The 2 functions that are called via the
I have a problem using Gin. Here is a simple example. @GinModules(AppModule.class) public interface
I´m have a problem using EF for my data model. I have this code
We have a problem using a class template which itself uses function objects in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.