public static int getNumOfMonths ( Date date1 , Date date2 ) { Calendar firstDate = Calendar . getInstance ( ) ; Date date = new Date ( date1 . getTime ( ) ) ; firstDate . setTime ( date ) ; Calendar secondDate = Calendar . getInstance ( ) ; Date date3 = new Date ( date2 . getTime ( ) ) ; secondDate . setTime ( date3 ) ; int months = firstDate . get ( Calendar . MONTH ) - secondDate . get ( Calendar . MONTH ) ; return months ; }
Gets the num of months .