I am trying to write function to find day difference between two date it work ok but the result change some time in the same inputs .Let say the current date is 21/7/2014 the result some time is 567 and other time 566.
The code:
    //TO GET THE CURRENT DATE
    Calendar cal = Calendar.getInstance();
    //THE CAL.ADD BECUSE THE 1ST MONTH IN THE YEAR IS 0 NOT 1
    cal.add(Calendar.MONTH, 1);
    //TO SET THE START DATE WICH IS 1/1/2013
    Calendar startDate=Calendar.getInstance();
    startDate.set(Calendar.DAY_OF_MONTH, 1);
    startDate.set(Calendar.MONTH,1);
    startDate.set(Calendar.YEAR, 2013);
    //TO FIND THE DIFF BETWEEN THE START DATE AND CUREENT DATE , THE +1 BECUSE IT IS           
    ALWAYS LESS BY ONE DAY
    long diff=(((cal.getTimeInMillis()- 
    startDate.getTimeInMillis())/(1000*60*60*24))+1);
 
     
     
    