get Month From Number - Android java.util

Android examples for java.util:Month

Description

get Month From Number

Demo Code

import android.content.Context;
import android.provider.Settings;
import android.telephony.PhoneNumberUtils;
import java.io.File;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Random;
import java.util.TimeZone;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{
    public static final String JANUARY = "January";

    public static final String FEBRUARY = "February";

    public static final String MARCH = "March";

    public static final String APRIL = "April";

    public static final String MAY = "May";

    public static final String JUNE = "June";

    public static final String JULY = "July";

    public static final String AUGUST = "August";

    public static final String SEPTEMBER = "September";

    public static final String OCTOBER = "October";

    public static final String NOVEMBER = "November";

    public static final String DECEMBER = "December";
    public static String getMonthFromNumber(String month) {
        if (month.equals("1") || month.equals("01")) {
            return JANUARY;
        } else if (month.equals("2") || month.equals("02")) {
            return FEBRUARY;
        } else if (month.equals("3") || month.equals("03")) {
            return MARCH;
        } else if (month.equals("4") || month.equals("04")) {
            return APRIL;
        } else if (month.equals("5") || month.equals("05")) {
            return MAY;
        } else if (month.equals("6") || month.equals("06")) {
            return JUNE;
        } else if (month.equals("7") || month.equals("07")) {
            return JULY;
        } else if (month.equals("8") || month.equals("08")) {
            return AUGUST;
        } else if (month.equals("9") || month.equals("09")) {
            return SEPTEMBER;
        } else if (month.equals("10") || month.equals("10")) {
            return OCTOBER;
        } else if (month.equals("11") || month.equals("11")) {
            return NOVEMBER;
        } else if (month.equals("12") || month.equals("12")) {
            return DECEMBER;
        } else {/*w  ww.j  a v a 2s. c  om*/
            return "";
        }
    }

}

Related Tutorials