Java Month Name Get monthNameAbbrev(int mon)

Here you can find the source of monthNameAbbrev(int mon)

Description

returns "jan", "feb", ..., "dec" for month number (1,2,...,12).

License

Open Source License

Parameter

Parameter Description
mon integer from 1 to 12.

Return

three character English month name.

Declaration

public static String monthNameAbbrev(int mon) 

Method Source Code

//package com.java2s;
/*/* www.  jav  a2s.c  o m*/
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

public class Main {
    private final static String[] mons = { "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct",
            "nov", "dec" };

    /**
     * returns "jan", "feb", ..., "dec" for month number (1,2,...,12).
     * @param mon integer from 1 to 12.
     * @return three character English month name.
     */
    public static String monthNameAbbrev(int mon) {
        if (mon < 1 || mon > 12)
            throw new IllegalArgumentException("invalid month number: " + mon);
        return mons[mon - 1];
    }
}

Related

  1. getPreMonthText(String pattern)
  2. month(String monthName)
  3. monthCalValue(String monthName)
  4. monthName(int month)
  5. monthName(int n)
  6. toMonthNameAbreviated(int m)