July 31, 20178 yr My timer is resetting after 5 seconds, and I'm not sure why. private long startTime; public void onStart() { startTime = System.currentTimeMillis(); } public final String formatTime(final long ms) { long s = ms / 1000, m = s / 60, h = m / 60; s %= 6; m %= 60; h %= 24; return String.format("%02d:%02d:%02d", h, m, s); } public void onPaint(Graphics2D g) { long runTime = System.currentTimeMillis() - startTime; g.drawString("Run Time :" + formatTime(runTime), 10, 290); } I put all the important bits down.
July 31, 20178 yr Author Never mind, I'm an idiot. public final String formatTime(final long ms) { long s = ms / 1000, m = s / 60, h = m / 60; s %= 6; m %= 60; h %= 24; return String.format("%02d:%02d:%02d", h, m, s); } Needs to be long s = ms / 1000, m = s / 60, h = m / 60; s %= 60; m %= 60; h %= 24;
July 31, 20178 yr Author 6 hours ago, Explv said: How do you fuck up a copy and paste lel Wasn't a coppyyy pastaa I typed it out to try and understand the lines and reasonings, makes it easier for me to remember how to do things. xD, why you roasting
July 31, 20178 yr 1 minute ago, kingbutton said: Wasn't a coppyyy pastaa I typed it out to try and understand the lines and reasonings, makes it easier for me to remember how to do things. xD, why you roasting If you want to understand it, read what he did and do your own version of a timer. This one is somewhat unique to avg timer classes.
Create an account or sign in to comment