public static int getMonthsDiffArray(Date startDate, Date endDate) {
int[] months = null;
Calendar startCalendar = new GregorianCalendar();
startCalendar.setTime(startDate);
Calendar endCalendar = new GregorianCalendar();
endCalendar.setTime(endDate);
int diffInMonths =
endCalendar.get(Calendar.MONTH) - startCalendar.get(Calendar.MONTH);
return diffInMonths;
}
//HH converts hour in 24 hours format (0-23), day calculation
SimpleDateFormat format =
new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
Date startDate = format.parse("04/14/2012 09:29:58");
Date endDate = format.parse("08/15/2012 10:31:48");