get Current Month as String from DateFormatSymbols - Android java.util

Android examples for java.util:Month

Description

get Current Month as String from DateFormatSymbols

Demo Code


//package com.java2s;

import java.text.DateFormatSymbols;
import java.util.Calendar;
import java.util.Locale;

public class Main {
    public static String getCurrentMonth(int monthIndex) {
        final Calendar calendar = Calendar.getInstance(Locale.getDefault());
        final DateFormatSymbols dateFormat = new DateFormatSymbols(
                Locale.getDefault());
        calendar.add(Calendar.MONTH, monthIndex);

        return dateFormat.getMonths()[calendar.get(Calendar.MONTH)];
    }//ww w.ja v  a2s. com
}

Related Tutorials