How do I use for loop for time? say keep looping for 5 minutes?

I need to keep looping for 5 minutes and if time is up exit.

what about this just small groovy:

def waitUnitll = new Date( new Date().getTime()+300000)
while (new Date() < waitUnitll){
println new Date()
WebUI.delay(30)
} 
2 Likes

Hello Liezl,

one of possible solutions:

// in secondslong timeout = 300
long timeStart = System.currentTimeMillis() / 1000Llong currentTime = System.currentTimeMillis() / 1000Lwhile (timeStart + timeout > currentTime) {	// do stuff	currentTime = System.currentTimeMillis() / 1000L}

2 Likes