java - How do I convert seconds into accumulated hhh:mm:ss? -


i want convert elapsed amount of accumulated seconds hours:minutes:seconds. example

93599 seconds to:

25:59:59

how can that? (note: 24h should not wrap 0h)

the modulus operator % useful here. work well

public static void converttime(int seconds) {     int secs = seconds % 60;     int mins = (seconds / 60) % 60;     int hours = (seconds / 60) / 60;     system.out.printf("%d:%d:%d", hours, mins, secs); } 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -