Here you can find the source of getInterval(String beginMonth, String endMonth)
public static int getInterval(String beginMonth, String endMonth)
//package com.java2s; 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 w w. jav a 2s . com }