Groovy web console

subscribe to the feed Subscribe
to this
site
Seconds to HH:mm:ss (via #groovywebconsole)
tweet this snippet Tweet
this
script

Seconds to HH:mm:ss

Published 2 months ago by Ibrahim with tags java time
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
int totalSecs = 3614
int hours = totalSecs / 3600;
int minutes = (totalSecs % 3600) / 60; 
int seconds = totalSecs % 60;  
String timeString = String.format("%02d:%02d:%02d", hours, minutes, seconds);
println timeString