I can’t resolve this question.
I wrote this code:
public static String getMonthName(int year, int month, int day){
Locale locale = Locale.getDefault();
SimpleDateFormat sdf = new SimpleDateFormat("MMMM",locale);
Date date = new Date();
date.setDate(day);
date.setMonth(month);
date.setYear(year);
return sdf.format(date);
}
It works very well but when month = 1 (that is February), month name is March and not February! Why?
This code works very well for all other days and months…
There is another way to get translated month name?
Please help me….
Depending on how you call your function (eg using current day as the 29 of Feb which doesn’t exist in 2013), you may make the month being incremented automatically.
I’d suggest the use of this function which avoids the problem :