Here you can find the source of getMonthCha(Date start, Date end)
public static int getMonthCha(Date start, Date end)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { public static int getMonthCha(Date start, Date end) { Calendar c1 = Calendar.getInstance(); Calendar c2 = Calendar.getInstance(); c1.setTime(start);/*from www .jav a 2 s . com*/ c2.setTime(end); int y1 = c1.get(Calendar.YEAR); int y2 = c2.get(Calendar.YEAR); int m1 = c1.get(Calendar.MONTH); int m2 = c2.get(Calendar.MONTH); int monthCha = (y2 - y1) * 12 + m2 - m1; return monthCha; } }