admin
2021-07-28 c0269fcfa876b9c5cf309b2006462b4d09c5ef95
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package com.hanju.video.app.ui.sohuutils;
 
public class FormatUtil {
    public static String milliSeconds2Time(int ms) {
        return seconds2Time(ms / 1000);
    }
 
    public static String seconds2Time(int sec) {
        if (sec < 0) {
            return "00:00";
        }
        int s = sec % 60;
        int m = sec / 60;
        return (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s;
    }
 
    public static String secondToString(long timeLength) {
        try {
            long l = timeLength;
            int timeLen = (int) l;
            int hour = timeLen / 3600;
            int minuter = (timeLen - 3600 * hour) / 60;
            int second = timeLen % 60;
            StringBuilder sb = new StringBuilder();
            if (hour < 10) {
                sb.append("0").append(hour);
            } else {
                sb.append(hour);
            }
            sb.append(":");
            if (minuter < 10) {
                sb.append("0").append(minuter);
            } else {
                sb.append(minuter);
            }
            sb.append(":");
            if (second < 10) {
                sb.append("0").append(second);
            } else {
                sb.append(second);
            }
            return sb.toString();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        } catch (Error er) {
            er.printStackTrace();
            return null;
        }
    }
}