How to calculate the date difference in Android?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you can’t afford 3rd party libraries like JodaTime, then your best bet is really
java.util.Calendar. You can use theCalendar#add()method in a loop to calculate the difference in years, months and days between two instances. Then to calculate the difference in hours, minutes and seconds, just do the usual math onCalendar#getTimeInMillis().Long story short, I’ve posted a basic example before here. You may find it useful.