Passed
Branch dev (d24a17)
by Etienne
01:34
created

de.kleiner3.lasertag.common.util.DurationUtils   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
eloc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A toString(Duration) 0 3 1
1
package de.kleiner3.lasertag.common.util;
2
3
import java.time.Duration;
4
5
/**
6
 * Utils for durations
7
 *
8
 * @author Étienne Muser
9
 */
10
public class DurationUtils {
11
    /**
12
     * Converts a duration into a string of format h:mm:ss
13
     * @param d The duration to convert
14
     * @return The converted string
15
     */
16
    public static String toString(Duration d) {
17
        var s = d.getSeconds();
18
        return String.format("%d:%02d:%02d", s / 3600, (s % 3600) / 60, (s % 60));
19
    }
20
}
21