title: Java Spring do scheduled task at a specific time of specific timezone
body: <p>I'm developing a website with Spring and Hibernate (the website is about stock trading). </p>
  
  <p>At about 12 AM everyday, I need to cancel all orders. Currently my solution is using a scheduled task that runs every hour:</p>
  
  <pre><code> &lt;task:scheduled ref="ordersController" method="timeoutCancelAllOrders" fixed-delay="60*60*1000" /&gt;
  </code></pre>
  
  <p>Then in the method timeoutCancelAllOrders, I get the current time and check, if it's between 11PM and 12AM then do the task</p>
  
  <p>The way I see it, task schedule starts when I start the Server ( I'm using Tomcat in Eclipse), but when I deploy it on an online hosting ( I'm using Openshift), I have no idea when is the starting time of task schedule.</p>
  
  <h2>My question is:</h2>
  
  <p>1: How to do it more automatic ? Is there anything like myTask.startAt(12AM) ?</p>
  
  <p>2: I'm living in Vietnam but the server (Openshift) is located in US, so here's how I do the check :</p>
  
  <pre><code>        Date currentTime = new Date();
      DateFormat vnTime = new SimpleDateFormat("hh:mm:ss MM/dd/yyyy ");
      vnTime.setTimeZone(TimeZone.getTimeZone("Asia/Ho_Chi_Minh"));
  
      String vietnamCurrentTime = vnTime.format(currentTime);
      String currentHourInVietnam = vietnamCurrentTime.substring(0, 2);
      System.out.println(currentHourInVietnam);
  
      if(currentHourInVietnam.equals("00")){
          // DO MY TASK HERE
      }
  </code></pre>
  
  <p>That looks stupid. How can I improve my code ?</p>