无关风月
2 天以前 88f2a615a6c547adfd992334f42d7cd4aea8d55b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package com.ruoyi.common.utils;
 
import java.util.concurrent.TimeUnit;
 
public class TimeConverter {
 
    public static String convertSecondsToHMS(Long seconds) {
        long hours = TimeUnit.SECONDS.toHours(seconds);
        long minutes = TimeUnit.SECONDS.toMinutes(seconds) % 60;
        long remainingSeconds = seconds % 60;
        return String.format("%02d",hours) + ":" + String.format("%02d",minutes) + ":" + String.format("%02d",remainingSeconds);
    }
 
//    public static void main(String[] args) {
//        Long totalSeconds = 44871L;
//        String hms = convertSecondsToHMS(totalSeconds);
//        System.out.println(hms);
//    }
}