title: Rescheduling a CronTriggerBean dynamically with same job details in Spring
body: <p>My task is to generate the reports dynamically with the scheduled time specified by the user from the GUI. </p>
  
  <p>I am using the following code in the application context of my application in spring to generate the report daily 6 A.M.. </p>
  
  <pre><code>&lt;bean name="scheduleRptJob" class="org.springframework.scheduling.quartz.JobDetailBean"&gt;
      &lt;property name="jobClass" value="com.secant.qatool.report.scheduler.ScheduleCroneJob"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="cronTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean"&gt;
      &lt;property name="jobDetail" ref="scheduleRptJob" /&gt;
  </code></pre>
  
  <p>
          
      </p>
  
  <pre><code>&lt;bean id="schedulerFactory"  class="org.springframework.scheduling.quartz.SchedulerFactoryBean"&gt;
      &lt;property name="triggers"&gt;
          &lt;list&gt;
              &lt;ref bean="cronTrigger"/&gt;
          &lt;/list&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I am changing the cron expression dynamically from the controller with the following code. But it is not working.</p>
  
  <pre><code>    String time[] = rptScheduleTime.split(":");
  
      String hours = time[0];
      String minutes = time[1];
  
      String croneExp = " 00 " + minutes + " " + hours + " * * ? ";
  
      log.debug("CRONE EXP :: " + croneExp);
  
      cronTrigger.clearAllTriggerListeners();
  
      // Setting the crown expression.
      cronTrigger.setCronExpression(croneExp);
  
      Trigger[] triggers = {cronTrigger};
  
      // Code to pause and start the cron trigger.
      schedulerFactory.stop();
      schedulerFactory.setTriggers(triggers);
      schedulerFactory.start();
  </code></pre>
  
  <p>Could someone please help me how to reschedule the same job with dynamic time.</p>
  
  <p>Thanks,</p>
  
  <p>-Anil Kumar.C</p>