Java examples for java.util:Month
get Months
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.LinkedList; import java.util.List; import java.util.Locale; public class Main { public static void main(String[] argv) throws Exception { System.out.println(getMonths()); }// w w w . j a v a2s .c o m private static final String MONTH_FULL_FORMAT = "MMMM"; public static List<String> getMonths(Locale locale) { List<String> res = new LinkedList<String>(); Calendar calendar = Calendar.getInstance(); for (int idx = calendar.getMinimum(Calendar.MONTH); idx <= calendar .getMaximum(Calendar.MONTH); idx++) { calendar.set(calendar.get(Calendar.YEAR), idx, 1); Date date = new Date(calendar.getTimeInMillis()); res.add(new SimpleDateFormat(MONTH_FULL_FORMAT, locale) .format(date)); } return res; } public static List<String> getMonths() { return getMonths(Locale.getDefault()); } }