Skip to content

Wait for Time

Renato Dell'Osso edited this page Aug 24, 2023 · 1 revision

Wait for Time

To wait for a certain amount of time, we must first make a LocalDateTime to track the start time, like so:

public LocalDateTime lastSwapTime;

Then, to start our timer:

lastSwapTime = LocalDateTime.now();

Finally, to check if the timer has completed:

if(LocalDateTime.now().compareTo(lastSwapTime.plusSeconds(Constants.TIMER_DURATION)) == 1) {
	//Timer has ended if this runs
	lastSwapTime = LocalDateTime.now(); //Reset the timer
}

Clone this wiki locally