Here’s a two line solution:
long msDiff = Calendar.getInstance().getTimeInMillis() - testCalendar.getTimeInMillis();
long daysDiff = TimeUnit.MILLISECONDS.toDays(msDiff);
In this example it gets the number of days between date “testCalendar” and the current date.
More Related Contents:
- Check if a given time lies between two times regardless of date
- How to save and retrieve Date in SharedPreferences
- Date value of a particular time in java [closed]
- How do I calculate someone’s age in Java?
- How to sanity check a date in Java
- Calendar date to yyyy-MM-dd format in java
- Android/Java – Date Difference in days
- Android: how to get the current day of the week (Monday, etc…) in the user’s language?
- How to get the first day of the current week and month?
- Date object SimpleDateFormat not parsing timestamp string correctly in Java (Android) environment
- How to subtract X day from a Date object in Java?
- Convert String to Calendar Object in Java
- Java Date vs Calendar
- Why does Java’s Date.getYear() return 111 instead of 2011?
- Why does Java’s Date.getYear() return 111 instead of 2011?
- Get Last Friday of Month in Java
- how to add days to java simple date format
- Getting last day of the month in a given string date
- Getting the current time millis from device and converting it into a new date with different timezone [duplicate]
- Android Studio Convert ISO string to “America/New_York” when adding to event to calendar
- How to Parse Date from GMT TimeZone to IST TimeZone and Vice Versa in android
- Java: Get month Integer from Date
- How to sanity check a date in Java
- How do I get difference between two dates in android?, tried every thing and post
- Sum two dates in Java
- Converting a Date object to a calendar object [duplicate]
- Retrieve current week’s Monday’s date
- Regex date validation for yyyy-mm-dd [duplicate]
- java get the first date and last date of given month and given year [duplicate]
- calculate number of weeks in a given year