Here you can find the source of calculateNextSettleDate(Date date, int addMonth)
public static Date calculateNextSettleDate(Date date, int addMonth)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static Date calculateNextSettleDate(Date date, int addMonth) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date);/*from w ww . jav a 2s . c o m*/ int dayOfMonth = calendar.get(Calendar.DAY_OF_MONTH); int maxOfMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); if (dayOfMonth == maxOfMonth) { calendar.add(Calendar.MONTH, addMonth); maxOfMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); calendar.set(Calendar.DAY_OF_MONTH, maxOfMonth); } else { calendar.add(Calendar.MONTH, addMonth); } return calendar.getTime(); } public static Date add(Date when, int field, int amount) { Calendar calendar = Calendar.getInstance(); calendar.setTime(when); calendar.add(field, amount); return calendar.getTime(); } }