Returns the Month string for a month number. - Java java.util

Java examples for java.util:Month

Description

Returns the Month string for a month number.

Demo Code


//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        int month = 2;
        System.out.println(getMonthAsString(month));
    }//  w  w w .  ja  v  a2 s  . c o m

    /**
     * Returns the Month string for a month number.
     * @param month Integer wich represents a month.
     * @return String of the month.
     */
    public static String getMonthAsString(int month) {
        String[] monthNames = { "January", "February", "March", "April",
                "May", "June", "July", "August", "September", "October",
                "November", "December" };
        return monthNames[month];
    }
}

Related Tutorials