Here you can find the source of dateAddMonths(Date date, int addMonths)
public static Date dateAddMonths(Date date, int addMonths)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static Date dateAddMonths(Date date, int addMonths) { if (date == null) return null; Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from w ww . jav a 2 s.c om*/ cal.add(Calendar.MONTH, addMonths); return cal.getTime(); } public static Date dateAddMonths(Date date, double months) { if (date == null) return null; int addMonths = (int) Math.ceil(months); int addDays = (int) Math.round((months - addMonths) * 31); Calendar cal = Calendar.getInstance(); cal.setTime(date); cal.add(Calendar.MONTH, addMonths); cal.add(Calendar.DATE, addDays); return cal.getTime(); } }