yongsing
asked on
Get num days between 2 Calendars
I have two Calendar objects, with their time fields (hour, minute, second, millisecond) all set to zeros. I want to get the days difference between these two objects.
Example:
Calendar 1: 2006-06-26
Calendar 2: 2006-06-27
results: -1
Calendar 1: 2006-06-26
Calendar 2: 2006-06-25
results: 1
Example:
Calendar 1: 2006-06-26
Calendar 2: 2006-06-27
results: -1
Calendar 1: 2006-06-26
Calendar 2: 2006-06-25
results: 1
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
from this you can get the difference of days,
int time = cal1.compareTo(cal2);
int days = time / 1000*60*60*24