kingbutton Posted July 31, 2017 Share Posted July 31, 2017 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. Quote Link to comment Share on other sites More sharing options...
kingbutton Posted July 31, 2017 Author Share Posted July 31, 2017 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; Quote Link to comment Share on other sites More sharing options...
Explv Posted July 31, 2017 Share Posted July 31, 2017 (edited) How do you fuck up a copy and paste lel Edited July 31, 2017 by Explv 1 Quote Link to comment Share on other sites More sharing options...
kingbutton Posted July 31, 2017 Author Share Posted July 31, 2017 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 Quote Link to comment Share on other sites More sharing options...
dreameo Posted July 31, 2017 Share Posted July 31, 2017 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. Quote Link to comment Share on other sites More sharing options...