| Total Complexity | 2 |
| Total Lines | 19 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package de.pewpewproject.lasertag.common.util; |
||
| 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 | /** |
||
| 22 | * Converts a duration into a string of format mm:ss. If the minutes go over 60 it simply counts up. eg 61, 62,... |
||
| 23 | * @param d The duration to convert |
||
| 24 | * @return The converted string |
||
| 25 | */ |
||
| 26 | public static String toMinuteString(Duration d) { |
||
| 27 | var s = d.getSeconds(); |
||
| 28 | return String.format("%02d:%02d", s / 60, (s % 60)); |
||
| 29 | } |
||
| 31 |