In order to run a background service I want to scedule a thread for running daily at 1am. How can I get this date in java?
Calendar cal = Calendar.getInstance();
cal.set(Calendar.HOUR_OF_DAY, HOUR_OF_EXECUTION);
Date date = cal.getTime();
did not work.
You should go for Quartz.
OR
Give firstExecuteDate accordingly and your thing has done, more over to get next execute – now
To get next date for time 1 pm.
Then subtract
currentMillis - (nextExecDate returned By above code)