aboutsummaryrefslogtreecommitdiff
path: root/src/net/brysonsteck/Resurrection/player/TimeCheck.java
blob: 4012e4881434711182a05e0b2163a1356297a0b7 (plain)
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
package net.brysonsteck.Resurrection.player;

import java.util.concurrent.TimeUnit;

public class TimeCheck {
    long millis;

    public TimeCheck(long millis) {
        this.millis = millis;
    }

    public String formatTime(char format) {
        // h = hours only, f = full time
        if (format == 'f') {
            return String.format("%d hrs, %d min, %d sec",
                    TimeUnit.MILLISECONDS.toHours(millis),
                    TimeUnit.MILLISECONDS.toMinutes(millis) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millis)),
                    TimeUnit.MILLISECONDS.toSeconds(millis) -
                            TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));
        } else if (format == 'h') {
            return String.format("%d hours",
                    TimeUnit.MILLISECONDS.toHours(millis));
        }
        return null;
    }
}