I want to show the name of the month in a recycler view, but I can't find the Locale.SPAIN option, and I have to show it in English. this is the adapter command that has to show the month:
holder.toma.setText("Mes: "+ getMonthName(listDatos.get(position).getMes(), Locale.US, false));
and this is the getMonthName function:
private String getMonthName(final int index, final Locale locale, final boolean shortName)
{
String format = "%tB";
if (shortName)
format = "%tb";
Calendar calendar = Calendar.getInstance(locale);
calendar.set(Calendar.MONTH, index);
calendar.set(Calendar.DAY_OF_MONTH, 1);
return String.format(locale, format, calendar);
}
To create a regional configuration for the Spanish language you must use:
example:
since currently the constants that exist to create configurations using the Locale class are only:
In the case of your code you can do it like this:
What happens is that Spain is not so cool ;)
At least for Java and Android development and that's why you should always check the official documentation. There are only a few pre-built Locales that use country names (China, US, UK, FRANCE, JAPAN, TAIWAN).
For the others, you have to use the LANGUAGE and COUNTRY codes to build the locale. Let's say, something like
new Locale("es", "ES")