Here you can find the source of getYearList(Calendar currDate)
public static ArrayList<LinkedHashMap<String, String>> getYearList(Calendar currDate)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.Calendar; import java.util.LinkedHashMap; public class Main { public static ArrayList<LinkedHashMap<String, String>> getYearList(Calendar currDate) { int prmBeforeCnt = 5; int prmAfterCnt = 5; return getYearList(currDate, prmBeforeCnt, prmAfterCnt); }/* www .j a va 2s . c o m*/ @SuppressWarnings("serial") public static ArrayList<LinkedHashMap<String, String>> getYearList(Calendar currDate, int prmBeforeCnt, int prmAfterCnt) { ArrayList<LinkedHashMap<String, String>> rtnYearList = new ArrayList<LinkedHashMap<String, String>>(); Calendar startDate = (Calendar) currDate.clone(); startDate.add(Calendar.YEAR, -1 * prmBeforeCnt); int startYear = startDate.get(Calendar.YEAR); Calendar endDate = (Calendar) currDate.clone(); endDate.add(Calendar.YEAR, prmAfterCnt); int endYear = endDate.get(Calendar.YEAR); for (int i = startYear; i <= endYear; i++) { final String year = Integer.toString(i); rtnYearList.add(new LinkedHashMap<String, String>() { { put("label", year); put("value", year); } }); } return rtnYearList; } public static String toString(Object stringObject) { return toString(stringObject, ""); } public static String toString(Object stringObject, String value2) { if (stringObject != null) { return stringObject.toString(); } else { return value2; } } }