I am trying to write code to find the day difference between two dates it work will when the month has 31 days but when the month has 30 days the result is less by 1 day this the case with 29 ,28 days month less by 2,3 days I hope I can know why the code :
public int dateAfterMod (Calendar endDate){
//TO GET THE CURRENT DATE
GregorianCalendar currentDate = new GregorianCalendar ();
currentDate=(GregorianCalendar) endDate;
//THE CAL.ADD BECUSE THE 1ST MONTH IN THE YEAR IS 0 NOT 1
currentDate.add(Calendar.MONTH, 1);
//TO SET THE DATE TO THE FIRST DAY IN THE MOTH FOR COMPAISSON
currentDate.set(Calendar.DAY_OF_MONTH, 1);
//TO SET THE START DATE WICH IS 1/1/2013
GregorianCalendar startDate = new GregorianCalendar(2013, 1, 1);
//TO FIND THE DIFF BETWEEN THE START DATE AND CUREENT DATE
long diff=(((currentDate.getTimeInMillis()-
startDate.getTimeInMillis())/(1000*60*60*24)));