get Month by int number - Android java.util

Android examples for java.util:Month

Description

get Month by int number

Demo Code

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main{

    public static String getMonth(int month) {
        String str = "Jan";

        switch (month) {
        case 1:/*w  ww  . j  a v a 2s .  com*/
            str = "Jan";
            break;
        case 2:
            str = "Feb";
            break;
        case 3:
            str = "Mar";
            break;
        case 4:
            str = "Apr";
            break;
        case 5:
            str = "Mei";
            break;
        case 6:
            str = "Jun";
            break;
        case 7:
            str = "Jul";
            break;
        case 8:
            str = "Agu";
            break;
        case 9:
            str = "Sep";
            break;
        case 10:
            str = "Okt";
            break;
        case 11:
            str = "Nov";
            break;
        case 12:
            str = "Des";
            break;
        }

        return str;
    }

}

Related Tutorials