mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-03 00:37:55 +00:00
Merge pull request #238 from Parabot/feature/timer-days
[Feature] Added days into Timer
This commit is contained in:
@@ -15,7 +15,6 @@ public class Timer {
|
|||||||
* @param end
|
* @param end
|
||||||
*/
|
*/
|
||||||
public Timer(long end) {
|
public Timer(long end) {
|
||||||
|
|
||||||
start = System.currentTimeMillis();
|
start = System.currentTimeMillis();
|
||||||
this.end = System.currentTimeMillis() + end;
|
this.end = System.currentTimeMillis() + end;
|
||||||
}
|
}
|
||||||
@@ -99,7 +98,7 @@ public class Timer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates string based on HH:MM:SS
|
* Generates string based on DD:HH:MM:SS
|
||||||
*
|
*
|
||||||
* @return String
|
* @return String
|
||||||
*/
|
*/
|
||||||
@@ -107,9 +106,16 @@ public class Timer {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
long elapsed = getElapsedTime();
|
long elapsed = getElapsedTime();
|
||||||
int second = (int) (elapsed / 1000 % 60);
|
int day = (int) (elapsed / 86400000);
|
||||||
int minute = (int) (elapsed / 60000 % 60);
|
elapsed -= day * 86400000;
|
||||||
int hour = (int) (elapsed / 3600000 % 60);
|
int hour = (int) (elapsed / 3600000);
|
||||||
|
elapsed -= hour * 3600000;
|
||||||
|
int minute = (int) (elapsed / 60000);
|
||||||
|
elapsed -= minute * 60000;
|
||||||
|
int second = (int) (elapsed / 1000);
|
||||||
|
if (day > 0) {
|
||||||
|
b.append(day).append("d:");
|
||||||
|
}
|
||||||
b.append(hour < 10 ? "0" : "").append(hour).append(":");
|
b.append(hour < 10 ? "0" : "").append(hour).append(":");
|
||||||
b.append(minute < 10 ? "0" : "").append(minute).append(":");
|
b.append(minute < 10 ? "0" : "").append(minute).append(":");
|
||||||
b.append(second < 10 ? "0" : "").append(second);
|
b.append(second < 10 ? "0" : "").append(second);
|
||||||
|
|||||||
Reference in New Issue
Block a user