Java Utililty Methods Month Name Get

List of utility methods to do Month Name Get

Description

The list of methods to do Month Name Get are organized into topic(s).

Method

StringgetMonthName(int MonthNumber)
get Month Name
String MonthName = " ";
switch (MonthNumber) {
case 0:
    MonthName = "January";
    break;
case 1:
    MonthName = "February";
    break;
...
StringgetMonthName(int monthNumber)
get Month Name
return months[monthNumber];
StringgetMonthName(String code)
get Month Name
if (code.equals("A"))
    return "Jan";
if (code.equals("B"))
    return "Feb";
if (code.equals("C"))
    return "Mar";
if (code.equals("D"))
    return "Apr";
...
StringgetMonthName(String dateString)
get Month Name
String returnString;
java.util.Date date = getDate(dateString);
SimpleDateFormat sdf = new SimpleDateFormat("MMM");
returnString = sdf.format(date);
return returnString;
StringgetMonthName(String month)
get Month Name
int n = Integer.parseInt(month);
if (n > 12 || n < 1) {
    throw new RuntimeException("Month num exceed range [1~12] : " + month);
return str[n];
ListgetMonthNames(Locale locale)
Returns a List of month name Strings - suitable for calendar headings.
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;
String[]getMonthNames(Locale locale)
Get an array of month names for a given locale.
SimpleDateFormat monthFormatter = new SimpleDateFormat("MMMM", locale);
String[] monthName = new String[12];
GregorianCalendar cal = new GregorianCalendar(2005, java.util.Calendar.JANUARY, 1);
for (int iMonth = 0; iMonth < 12; iMonth++) {
    monthName[iMonth] = monthFormatter.format(cal.getTime());
    cal.add(java.util.Calendar.MONTH, 1);
return monthName;
...
StringgetMonthSelect(String selectName, String value, boolean hasBlank)
get Month Select
StringBuffer sb = new StringBuffer("");
sb.append("<select name=\"" + selectName + "\">");
if (hasBlank) {
    sb.append("<option value=\"\"></option>");
for (int i = 1; i <= 12; i++) {
    if (!value.trim().equals("") && i == Integer.parseInt(value)) {
        sb.append("<option value=\"" + i + "\" selected>" + i + "</option>");
...
StringgetMonthStr(int month)
get Month Str
String monthInChinese = "";
switch (month) {
case 1: 
    monthInChinese = "\u4E00\u6708";
    break;
case 2: 
    monthInChinese = "\u4E8C\u6708";
    break;
...
StringgetMonthStr(int month)
get Month Str
String[] monthName = { "January", "February", "March", "April", "May", "June", "July", "August",
        "September", "October", "November", "December", };
if (month < 0 | month >= 12) {
    return "";
} else {
    return monthName[month];