Format seconds integer to time in Groovy
groovy
Solution
String timestamp =
new GregorianCalendar( 0, 0, 0, 0, 0, 990, 0 ).time.format( 'HH:mm:ss' )
From duration to seconds:
long seconds = ( Date.parse( 'HH:mm:ss', '00:16:30' ).time -
Date.parse( 'HH:mm:ss', '00:00:00' ).time ) / 1000
Problem
I have a variable containing time in seconds like `990` which would be 16 minutes 30 seconds. How do I convert this to time `00:16:30` in Groovy? Along the same lines, how do I convert it the other way around?