userJP userJP - 5 months ago 17
Android Question

Get current month full name in android

In my project, i have a spinner for choose month and I want to display current month as default selected. I have string array in


<string-array name="Months">

In MainActivity, I set adapter to the spinner,

ArrayAdapter<CharSequence> monthAdapter = ArrayAdapter
.createFromResource(this, R.array.Months, R.layout.spinner_item);

I use these two functions, these function are static because the functions are used in many activities.

public static int setCurrentMonthSpinner (Context context) {
String[] months = context.getResources().getStringArray(R.array.Months);
for (int i = 0; i < months.length; i++) {
String mnth = Util.getCurrentMonth();
if (months[i].equals(mnth))
return i;
return 0;

and second method is...

public static String getCurrentMonth () {
Calendar cal = Calendar.getInstance();
SimpleDateFormat month_date = new SimpleDateFormat("MMMMMM");

return month_date.format(cal.getTime());

The method getCurrentMonth returns current month name like Jan or Feb but i want to get return String like January or February. Guide me...


Try adding a locale to your SimpleDateFormat like this:

SimpleDateFormat month_date = new SimpleDateFormat("MMMM", Locale.US);