将秒数转换为时分秒的形式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);
    }
}

供小伙伴们参考!

posted @ 2018-09-26 17:32  FineYoung  阅读(1345)  评论(0编辑  收藏  举报