Search code examples
androidcalendar

Month name as a string


I'm trying to return the name of the month as a String, for instance "May", "September", "November".

I tried:

int month = c.get(Calendar.MONTH);

However, this returns integers (5, 9, 11, respectively). How can I get the month name?


Solution

  • Use getDisplayName.

    For earlier API's use String.format(Locale.US,"%tB",c);