Jump to content

Getting run time, then painting run time to screen


Federal

Recommended Posts

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

  • Like 1
Link to comment
Share on other sites

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

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...