Reputation: 985
I am new in Android.I can't find any way to calculate the time difference.So please help me. I designed a simple application. In this program I took 3 EditTexts and in these EditText I want to input the login time and logout time then store these values in the Database, And in the 3rd EditText I want to display the difference between these two time.
Upvotes: 14
Views: 27447
Reputation: 5795
An easier approach -
Date interestingDate = new Date();
different in milliseconds between the actual current date and interestingDate by doing:
(new Date()).getTime() - interestingDate.getTime();
Check the referenced answer in this link.
Upvotes: 9
Reputation: 2023
You can use standard Java api calls:
System.nanoTime()
System.currentTimeMillis()
Also, check out these two links for calculating time difference.
Upvotes: 16