Federal Posted May 16, 2014 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
PolishCivil Posted May 16, 2014 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
Federal Posted May 16, 2014 Author 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)