Here you can find the source of getInterval(String beginMonth, String endMonth)
public static int getInterval(String beginMonth, String endMonth)
//package com.java2s; //License from project: Apache License public class Main { public static int getInterval(String beginMonth, String endMonth) { int intBeginYear = Integer.parseInt(beginMonth.substring(0, 4)); int intBeginMonth = Integer.parseInt(beginMonth .substring(beginMonth.indexOf("-") + 1)); int intEndYear = Integer.parseInt(endMonth.substring(0, 4)); int intEndMonth = Integer.parseInt(endMonth.substring(endMonth .indexOf("-") + 1)); return ((intEndYear - intBeginYear) * 12) + (intEndMonth - intBeginMonth) + 1; }//from w ww.j av a 2 s.c o m }