Java Month month2String(int month)

Here you can find the source of month2String(int month)

Description

Examine an int and determine if it is a month.

License

Open Source License

Parameter

Parameter Description
month A given month as an int.

Return

A String value representing the month.

Declaration

public static String month2String(int month) 

Method Source Code

//package com.java2s;
/*/*  www .  j a v  a2s.com*/
This file is part of JFLICKS.
    
JFLICKS is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
    
JFLICKS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
    
You should have received a copy of the GNU General Public License
along with JFLICKS.  If not, see <http://www.gnu.org/licenses/>.
*/

public class Main {
    /**
     * Examine an int and determine if it is a month.  If so then return a
     * String value where 0 = January, 1 = February, etc.
     *
     * @param month A given month as an int.
     * @return A String value representing the month.
     */
    public static String month2String(int month) {

        String result = "January";

        if (month == 0) {
            result = "January";
        } else if (month == 1) {
            result = "February";
        } else if (month == 2) {
            result = "March";
        } else if (month == 3) {
            result = "April";
        } else if (month == 4) {
            result = "May";
        } else if (month == 5) {
            result = "June";
        } else if (month == 6) {
            result = "July";
        } else if (month == 7) {
            result = "August";
        } else if (month == 8) {
            result = "September";
        } else if (month == 9) {
            result = "October";
        } else if (month == 10) {
            result = "November";
        } else if (month == 11) {
            result = "December";
        }

        return (result);
    }
}

Related

  1. lookupMonthStr(int month)
  2. maxLengthOfMonth(int month)
  3. MONTH(int mh)
  4. month2int(String month)
  5. month2second(int month)
  6. monthAlphaToNum(String str)
  7. monthDiff(String beforeTime, String endTime)
  8. monthFromDateValue(long x)
  9. monthLength(int year, int month)