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.
Asked
Active
Viewed 2.7k times
2 Answers
16
You can use standard Java api calls:
System.nanoTime()
System.currentTimeMillis()
Also, check out these two links for calculating time difference.

Community
- 1
- 1

dSebastien
- 1,983
- 2
- 21
- 31
-
In addition to the above check [this answer](http://stackoverflow.com/questions/4927856/how-to-calculate-time-difference-in-java) – Reno Feb 26 '11 at 16:05
9
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.