Ihsan chahi
Ihsan chahi

Reputation: 307

How to calculate time in android .?

I want to calculate time after a button pressed ,so that i can keep track that this much has been passed.I have search it and find that android timer can do that but i couldn't get any useful answer for that.

Thanks in advance.

Upvotes: 0

Views: 3701

Answers (2)

user2483079
user2483079

Reputation: 533

On start button press:

long start = System.currentTimeMillis();

On update/end button press:

long runTime = System.currentTimeMillis() - start;

Upvotes: 2

Rajeev
Rajeev

Reputation: 1404

if you only want to calculate time difference between two events then you can use System.currentTimeMillis();.

Upvotes: 0

Related Questions