Java Month Name Get getMonthName()

Here you can find the source of getMonthName()

Description

Get full name of the current month

License

LGPL

Return

The full name of the current month

Declaration

public static String getMonthName() 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.util.Calendar;

public class Main {
    /**/* w ww .ja  v  a  2  s .  co  m*/
     * Get full name of the current month
     * @return The full name of the current month
     */
    public static String getMonthName() {
        Calendar cal = Calendar.getInstance();
        int month = cal.get(Calendar.MONTH);
        String strMonth;
        switch (month) {
        case Calendar.JANUARY:
            strMonth = "Jan";
            break;

        case Calendar.FEBRUARY:
            strMonth = "Feb";
            break;

        case Calendar.MARCH:
            strMonth = "Mar";
            break;

        case Calendar.APRIL:
            strMonth = "Apr";
            break;

        case Calendar.MAY:
            strMonth = "May";
            break;

        case Calendar.JUNE:
            strMonth = "June";
            break;

        case Calendar.JULY:
            strMonth = "July";
            break;

        case Calendar.AUGUST:
            strMonth = "Aug";
            break;

        case Calendar.SEPTEMBER:
            strMonth = "Sept";
            break;

        case Calendar.OCTOBER:
            strMonth = "Oct";
            break;

        case Calendar.NOVEMBER:
            strMonth = "Nov";
            break;

        case Calendar.DECEMBER:
            strMonth = "Dec";
            break;

        default:
            strMonth = "ERROR";
            break;
        }
        return strMonth;
    }
}

Related

  1. getDutchMonthName(int monthNumber)
  2. getMonth(boolean name)
  3. getMonth(String monthName)
  4. getMonthByName(String monthName)
  5. getMonthFromMonthName(String name)
  6. getMonthName(Date date)
  7. getMonthName(int index)
  8. getMonthName(int month, Locale locale)
  9. getMonthName(int MonthNumber)