stringify Workout Time - Java java.util

Java examples for java.util:Time

Description

stringify Workout Time

Demo Code


//package com.java2s;

public class Main {
    public static String stringifyWorkoutTime(int time) {
        int hours = (time / 60) / 60;
        int mins = (time / 60) % 60;
        int secs = (time % 60);

        if (hours == 0 && mins == 0 && secs == 0) {
            return new String("--:--:--");
        }/*  w ww.j  a v  a 2s  .  c o  m*/
        return new String(hours + ":" + String.format("%02d", mins) + ":"
                + String.format("%02d", secs));
    }
}

Related Tutorials