Calendar today = Calendar.getInstance();
today.set(Calendar.HOUR_OF_DAY, 2);
today.set(Calendar.MINUTE, 0);
today.set(Calendar.SECOND, 0);
// every night at 2am you run your task
Timer timer = new Timer();
timer.schedule(new YourTask(), today.getTime(), TimeUnit.MILLISECONDS.convert(1, TimeUnit.DAYS)); // period: 1 day
Related Contents:
- Java Timer vs ExecutorService?
- Android Timer schedule vs scheduleAtFixedRate
- System.currentTimeMillis vs System.nanoTime
- How to timeout a thread
- How to schedule a periodic task in Java?
- java: run a function after a specific number of seconds
- How to set a Timer in Java?
- Print “hello world” every X seconds
- scheduleAtFixedRate vs scheduleWithFixedDelay
- How to stop the task scheduled in java.util.Timer class
- Timer & TimerTask versus Thread + sleep in Java
- How to conditionally enable or disable scheduled jobs in Spring?
- Does spring @Scheduled annotated methods runs on different threads?
- Scheduling a job with Spring programmatically (with fixedRate set dynamically)
- Run a java function after a specific number of seconds
- How do I schedule a task to run at periodic intervals?
- DropWizard Metrics Meters vs Timers
- What’s the difference between fixed rate and fixed delay in Spring Scheduled annotation?
- How to stop a Runnable scheduled for repeated execution after a certain number of executions
- Spring Scheduler stops unexpectedly
- What is the equivalent of javascript setTimeout in Java?
- How do I calculate the elapsed time of an event in Java? [duplicate]
- Android timer updating a textview (UI)
- Android: CountDownTimer skips last onTick()!
- How to stop a scheduled task that was started using @Scheduled annotation?
- Execute function after 5 seconds in Android
- Spring scheduling task – run only once
- Should I initialize variable within constructor or outside constructor [duplicate]
- String.valueOf() vs. Object.toString()
- Converting a Java Keystore into PEM Format
- What is the most efficient Java Collections library? [closed]
- How can I “pretty print” a Duration in Java?
- Conveniently map between enum and int / String
- Functional programming – is immutability expensive? [closed]
- Java JTable setting Column Width
- How can I get the count of line in a file in an efficient way? [duplicate]
- How to supply Enum value to an annotation from a Constant in Java
- Is a Java int always 32 bits?
- Use an array as a case statement in switch
- Spring Security permitAll not allowing anonymous access
- What are the differences between abstract classes and interfaces in Java 8?
- Remove end of line characters from Java string
- Java.nio: most concise recursive directory delete
- Java Generic Class – Determine Type
- JAX-RS Frameworks [closed]
- Why doesn’t changing the pre to the post increment at the iteration part of a for loop make a difference?
- Java object analogue to R data.frame [closed]
- Java: how to get a File from an escaped URL?
- a = (a++) * (a++) gives strange results in Java [closed]
- Why do I get an Enum constant reference cannot be qualified in a case label?