API call every day at a specific time in Java with Spring?
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. https://www.mkyong.com/java/how-to-run-a-task-periodically-in-java/. But then is there any other way to do that in java? I am looking for the most efficient approach. Any suggestions.
@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;
}
}