Federal Posted May 16, 2014 Share Posted May 16, 2014 Hey, does anyone know how I can get the run time from the start of my script, and then paint it out onto the screen? Help is appreciated, Thanks Link to comment Share on other sites More sharing options...
Wiz Khalifa Posted May 16, 2014 Share Posted May 16, 2014 http://www.tutorialspoint.com/java/ Link to comment Share on other sites More sharing options...
PolishCivil Posted May 16, 2014 Share Posted May 16, 2014 System.currenttimemilis() returns current syste time in miliseconds So: onstart() -> startTime = System.currenttimemilis() onPaint() -> timeElapsed = System.currentTimeMilis() - startTime; Then u can do long second = (timeElapsed / 1000) % 60 long minute = (timeElapsed / (1000 * 60)) % 60 long hour = (timeElapsed / (1000 * 60 * 60)) % 24 1 Link to comment Share on other sites More sharing options...
Federal Posted May 16, 2014 Author Share Posted May 16, 2014 System.currenttimemilis() returns current syste time in miliseconds So: onstart() -> startTime = System.currenttimemilis() onPaint() -> timeElapsed = System.currentTimeMilis() - startTime; Then u can do long second = (timeElapsed / 1000) % 60 long minute = (timeElapsed / (1000 * 60)) % 60 long hour = (timeElapsed / (1000 * 60 * 60)) % 24 Thanks a lot for that, but do you have an idea on how to put those milliseconds into hh:mm:ss? (e.g. 5:12:55, 5 hours, 12 minutes and 55 seconds) Link to comment Share on other sites More sharing options...
Ziy Posted May 16, 2014 Share Posted May 16, 2014 String.format("%d:%02d:%02d", hour, minute, second); Link to comment Share on other sites More sharing options...