public static int addMonths ( int date , int m ) { int y0 = ( int ) DateTimeUtils . unixDateExtract ( TimeUnitRange . YEAR , date ) ; int m0 = ( int ) DateTimeUtils . unixDateExtract ( TimeUnitRange . MONTH , date ) ; int d0 = ( int ) DateTimeUtils . unixDateExtract ( TimeUnitRange . DAY , date ) ; int y = m / 12 ; y0 += y ; m0 += m - y * 12 ; int last = lastDay ( y0 , m0 ) ; if ( d0 > last ) { d0 = 1 ; if ( ++ m0 > 12 ) { m0 = 1 ; ++ y0 ; } } return DateTimeUtils . ymdToUnixDate ( y0 , m0 , d0 ) ; }
Adds a given number of months to a date represented as the number of days since the epoch .