title: API call every day at a specific time in java?
body: <p>I want to create a scheduler in java which makes an API calls every day at a specific time and saves the content in a text file. One option would be to do something like this. <a href="https://www.mkyong.com/java/how-to-run-a-task-periodically-in-java/" rel="nofollow noreferrer">https://www.mkyong.com/java/how-to-run-a-task-periodically-in-java/</a>. But then is there any other way to do that in java? I am looking for the most efficient approach. Any suggestions.</p>
  
  <pre><code>@Component
      class WelcomeService {
  
          public String retrieveWelcomeMessage() {
              //Complex Method
               String msgType="Hello World";
               RestTemplate restTemplate = new RestTemplate();
             String consumeJSONString = restTemplate.getForObject("https://ubasocials.ubagroup.com/geo-locationservice/odata/ATMs", String.class);
             writetexttofile(consumeJSONString);
  
            /* Gson gson = new GsonBuilder().create();
              Quote r = gson.fromJson(consumeJSONString, Quote.class);
              msgType=r.getValue().getQuote();*/
              return msgType;
          }
  } 
  </code></pre>