title: How to run a particular task every week, every month and every six month?
body: <p>I am working on making a cron job in Java. I want to run a particular task every week, month, three month, six month and nine month.</p>
  
  <pre><code>public Interface interfaceA {
      public String abc() throws Exception;
  }
  
  public class TestTaskA implements interfaceA {
  
      @Override
      public String abc() throws Exception {
          // some code
      }
  }
  </code></pre>
  
  <p>I am running it like this - </p>
  
  <pre><code>TestTaskA testTaskA = new TestTaskA();
  testTaskA.abc();    
  </code></pre>
  
  <p>I want to run <code>TestTaskA</code> every week, every month, every three month, every six month, every nine month and I don't want to run a task between 8 PM till 5 AM. Any random day is also fine.</p>
  
  <p>Now if I am running <code>TestTaskA</code> every week, then it should print out <code>one-week</code> and <code>report_week</code> and if it is running every month, then it should print out <code>one-month</code> and <code>report_one_month</code>. Similarly for three month, six month and nine month.</p>
  
  <p>What is the best way to do this? Keeping in mind, I might have TestTaskB and TestTaskC as well which I am supposed to run every week, month, three month, six month and nine month as well.</p>
  
  <p>Can I use <code>ScheduledExecutorService</code> for this? Any simple example will be of great help to me.</p>