I am trying to use getDisplayNames()
on a Calendar object in my Android code. I have java.util.Calendar
included and haven't had any troubles using any other public members of the Calendar class (i.e. Calendar.MONTH). Now I am attempting the following line...
mReminderCal.getDisplayName(Calendar.DAY_OF_MONTH, Calendar.LONG, Locale.US)
And Eclipse is telling me Calendar.LONG
or Calendar.SHORT
don't exist.
According to the documentation here they should exist: http://developer.android.com/reference/java/util/Calendar.html#LONG
Any insight?
Try This (same for Gregorian or regular calendar). DateFormatSymbols is API level 1.
int month = date.get(GregorianCalendar.MONTH);
String monthName = new DateFormatSymbols().getMonths()[month];
I found the issue.
The getDisplayName()
and associated Calendar.LONG
and Calendar.SHORT
are API level 9 only. I'm on API level 4 for backwards compatibility. I suppose, I will have to create my own function to translate the month enums into strings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With