无关风月
2 天以前 ce0651907f18a57dae80065e01589e975530f53e
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);
    }
}