Q:

Elapsed Months calculation not giving correct result for dates with current month and day but a different year

I am trying to calculate months elapsed since a particular date, the function works fine albeit it gives me a one months difference (Less than one month) if I put a date of today with a different year of the past.  
Say for all dates the function works well, except: 
If it is "2014-03-06" (YYYY,MM,DD) today and I process a date as "2006-03-06" to the function, the result is one month shorter, however if I use the same date tomorrow, the result is just fine.  WOnder where I am going wrong.  Below is the code: 
public static int months(String d) {

        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
        Date d1 = null;
        try {
            d1 = f.parse(d);
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        //   Date d2 = (getCurrentDate());
        Date d2 = getCurrentDate(); 
        Calendar c1 = Calendar.getInstance();
        c1.setTime(d1);
        Calendar c2 = Calendar.getInstance();
        c2.setTime(d2);
        int diff = 0;
        if (c2.after(c1)) {
            while (c2.after(c1)) {
                c1.add(Calendar. MONTH, 1);
                if (c2.after(c1)) {
                    diff++;
                }
            }
        } else if (c2.before(c1)) {
            while (c2.before(c1)) {
                c1.add(Calendar. MONTH, -1);
                if (c1.before(c2)) {
                    diff--;
                }
            }
        }
        System.out.println(diff);
        return diff;
    }

Result: 95 months. 
Ideally it should be 96 months. 
Please dont consider the static nature of functions, I have isolated this code in a different project for test purpose.  
This is the value of c1 and c2: 
java.util. GregorianCalendar[time=1141583400000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar. ZoneInfo[id="Asia/Kolkata",offset=19800000,dstSavings=0,useDaylight=false,transitions=6,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2006,MONTH=2,WEEK_OF_YEAR=10,WEEK_OF_MONTH=2,DAY_OF_MONTH=6,DAY_OF_YEAR=65,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=19800000,DST_OFFSET=0] and c2 is: java.util. GregorianCalendar[time=1394044200000,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar. ZoneInfo[id="Asia/Kolkata",offset=19800000,dstSavings=0,useDaylight=false,transitions=6,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2014,MONTH=2,WEEK_OF_YEAR=10,WEEK_OF_MONTH=2,DAY_OF_MONTH=6,DAY_OF_YEAR=65,DAY_OF_WEEK=5,DAY_OF_WEEK_IN_MONTH=1,AM_PM=0,HOUR=0,HOUR_OF_DAY=0,MINUTE=0,SECOND=0,MILLISECOND=0,ZONE_OFFSET=19800000,DST_OFFSET=0]
95

My bad here is the getCurrentDate():
public static Date getCurrentDate() {
        String DateStr = new SimpleDateFormat("yyyy-MM-dd"/*,
                current*/).format(Calendar.getInstance().getTime());
        //  String DateStr = formattedDate;
        Date date = null;
        try {
            date = new SimpleDateFormat("yyyy-MM-dd"/*, current*/).parse(DateStr);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        java.sql. Date dx = new java.sql. Date(date.getTime());
        return dx;
    }

A:

Check your getCurrentDate() method.  I have replaced with new Date() and output is 96 as you said.