Here you can find the source of getMonthRange(String start, String end)
public static int getMonthRange(String start, String end)
//package com.java2s; public class Main { public static int getMonthRange(String start, String end) { int range = 0; try {/*from w w w.j a v a 2 s.c o m*/ String yearEnd = end.substring(0, 4); String monthEnd = end.substring(4); String yearStart = start.substring(0, 4); String monthStart = start.substring(4); range = (Integer.parseInt(yearEnd) - Integer.parseInt(yearStart)) * 12 + Integer.parseInt(monthEnd) - Integer.parseInt(monthStart) + 1; } catch (Exception e) { e.printStackTrace(); } return range; } }