From f75681144085e729b4e9972908c1fc859670bb4b Mon Sep 17 00:00:00 2001 From: Bryson Steck Date: Thu, 19 Aug 2021 21:58:40 -0600 Subject: added h and f mods for timecheck.formattime --- .../brysonsteck/Resurrection/player/TimeCheck.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/net/brysonsteck/Resurrection/player/TimeCheck.java') diff --git a/src/net/brysonsteck/Resurrection/player/TimeCheck.java b/src/net/brysonsteck/Resurrection/player/TimeCheck.java index a12bb16..4012e48 100644 --- a/src/net/brysonsteck/Resurrection/player/TimeCheck.java +++ b/src/net/brysonsteck/Resurrection/player/TimeCheck.java @@ -9,11 +9,18 @@ public class TimeCheck { this.millis = millis; } - public String formatTime() { - 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))); + 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; } } -- cgit v1.2.3