Here you can find the source of getMonthDiff(Calendar c1, Calendar c2)
public static int getMonthDiff(Calendar c1, Calendar c2)
//package com.java2s; //License from project: LGPL import java.util.Calendar; public class Main { public static int getMonthDiff(Calendar c1, Calendar c2) { int mon1 = c1.get(Calendar.MONTH); int mon2 = c2.get(Calendar.MONTH); int y1 = c1.get(Calendar.YEAR); int y2 = c2.get(Calendar.YEAR); return (y2 - y1) * 12 + mon2 - mon1; }/*from ww w.ja v a 2 s . co m*/ }