Here you can find the source of getMonthBetween(Date data1, Date data2)
public static int getMonthBetween(Date data1, Date data2)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static int getMonthBetween(Date data1, Date data2) { Calendar ca1 = Calendar.getInstance(); Calendar ca2 = Calendar.getInstance(); ca1.setTime(data1);/*from w w w.j av a 2 s . co m*/ ca2.setTime(data2); return ca2.get(Calendar.MONTH) - ca1.get(Calendar.MONTH); } }