get Month from int - Java java.util

Java examples for java.util:Month

Description

get Month from int

Demo Code

/**//from  ww w . j  a va  2  s.c om
 * Java
 *
 * Copyright 2014 IS2T. All rights reserved.
 * Use of this source code is governed by a BSD-style license that can be found at http://www.is2t.com/open-source-bsd-license/.
 */
//package com.java2s;

public class Main {
    public static void main(String[] argv) throws Exception {
        int month = 2;
        System.out.println(getMonth(month));
    }

    private static final String[] MONTHS = new String[] { "January",
            "February", "March", "April", "May", "June", "July", "August",
            "September", "October", "November", "December" };

    public static String getMonth(int month) {
        return MONTHS[month];
    }
}

Related Tutorials