I have one application that receives the start and end time from the user and starts a specific process at (start time) runs to (end time), for example, I use the TimerTask utility if it only starts the process from the current time and runs to (end time), I can not set the start time, how can I compare the user time (start time) and the system time in java
import java.sql.Date;
import java.util.Timer;
import java.util.TimerTask;
public class Main {
public static void main(String[] argv) throws Exception {
int numberOfMillisecondsInTheFuture=1000;
Date timeToRun = new Date(System.currentTimeMillis() + numberOfMillisecondsInTheFuture);
Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
}
}, timeToRun);
}
source
share