将秒数转换为时分秒的形式java形式

将一个秒数转换为时分秒形式,例如91秒=00:01:31 

public class Main {
    public static void main(String[] args) {
        System.out.println(transfom(3665));
    }

    public static String transfom(final int time) {
        int hh = time / 3600;
        int mm = (time % 3600) / 60;
        int ss = (time % 3600) % 60;
        return (hh < 10 ? ("0" + hh) : hh) + ":" + (mm < 10 ? ("0" + mm) : mm) + ":" + (ss < 10 ? ("0" + ss) : ss);
    }
}

供小伙伴们参考!

猜你喜欢

转载自www.cnblogs.com/yangfan326/p/9708334.html
今日推荐