Java将秒数转换成X时X分X秒格式

例如:将3666秒转换成1时1分6秒

public static void main() {
    int seconds = 3666;
    int h = seconds / 3600;
    int m = seconds % 3600 / 60;
    int s = seconds % 60;
    System.put.print(h + "时" + m + "分" + s + "秒");
}
posted @ 2024-05-17 12:02  山城大叔  阅读(122)  评论(0)    收藏  举报