Here you can find the source of divMonth(Date startDate, Date enDate)
public static int divMonth(Date startDate, Date enDate)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static int divMonth(Date startDate, Date enDate) { Calendar startCalendar = Calendar.getInstance(); startCalendar.setTime(startDate); Calendar endCalendar = Calendar.getInstance(); endCalendar.setTime(enDate);/*from w ww.ja v a 2 s . c om*/ int yearDiv = startCalendar.get(Calendar.YEAR) - endCalendar.get(Calendar.YEAR); int monthDiv = startCalendar.get(Calendar.MONTH) - endCalendar.get(Calendar.MONTH); return monthDiv + yearDiv * 12; } }