Having a java function run every day at a certain time.
Go to solution
Solved by BobVonBob,
3 minutes ago, DriedSponge said:I need it to run at a specific time of day.
In that case, I'm completely stumped why this prior code didn't work. Are you sure you had the hour and minute set after the local time of your computer when you ran it?
class TimerThing { public static void main() { Timer timer = new Timer(); Calendar date = Calendar.getInstance(); date.set(Calendar.HOUR, 13); date.set(Calendar.MINUTE, 21); date.set(Calendar.SECOND, 0); date.set(Calendar.MILLISECOND, 0); timer.schedule( new TimerTask() { @Override public void run() { System.out.println("Test"); } }, date.getTime(), 1000 * 60 * 60 * 24 ); } }

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now