Here you can find the source of getMonthNames(Locale locale)
Parameter | Description |
---|---|
locale | a parameter |
public static List<String> getMonthNames(Locale locale)
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.List; import java.util.Locale; public class Main { /**//from www . j av a 2s . co m * Returns a List of month name Strings - suitable for calendar headings. * * @param locale * @return List of month name Strings */ public static List<String> getMonthNames(Locale locale) { Calendar tempCal = Calendar.getInstance(locale); tempCal.set(Calendar.MONTH, Calendar.JANUARY); SimpleDateFormat dateFormat = new SimpleDateFormat("MMMM", locale); List<String> resultList = new ArrayList<String>(); for (int i = Calendar.JANUARY; i <= tempCal.getActualMaximum(Calendar.MONTH); i++) { resultList.add(dateFormat.format(tempCal.getTime())); tempCal.roll(Calendar.MONTH, 1); } return resultList; } }