How to get Month name ??
lazy-coder-10 opened this issue · comments
Rohit Singh commented
I was trying to get month name. is there any way to get month name without using external code ??
Prem Kumar Koti commented
@rohit6027 Right now once the user selects the month and year you will get the month number (Range from 0 to 11). You can use Calendar class or DateFormatSymbols to get the month name.
Ex:
Using Calender Class :
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMMM", Locale.getDefault());
Calendar calendar=Calendar.getInstance();
calendar.set(Calendar.MONTH,selectedMonth);
String selectedMonthName = simpleDateFormat.format(calendar.getTime());
Log.d(TAG, "selected month name : "+selectedMonthName);
Using DateFormatSymbols :
String[] _monthNames = new DateFormatSymbols(Locale.getDefault()).getMonths();
String selectedMonthName = _monthNames[selectedMonth];
Log.d(TAG, "selected month name : "+selectedMonthName);
Rohit Singh commented
I do know this answer. I thought your library may give month name without
using that code.
Thanks for your reply. I have defined a static months array and based on
that no. I am picking month name from array.
…On Wed, Sep 5, 2018, 2:09 PM Prem Kumar Koti ***@***.***> wrote:
Right now once the user selects the month and year you will get the month
number (Range from 0 to 11). You can use Calendar class or
DateFormatSymbols to get the month name.
Ex:
Using Calender Class :
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMMM", Locale.getDefault());
Calendar calendar=Calendar.getInstance();
calendar.set(Calendar.MONTH,selectedMonth);
String selectedMonthName = simpleDateFormat.format(calendar.getTime());
Log.d(TAG, "selected month name : "+selectedMonthName);
Using DateFormatSymbols :
String[] _monthNames = new DateFormatSymbols(Locale.getDefault()).getMonths();
String selectedMonthName = _monthNames[selectedMonth];
Log.d(TAG, "selected month name : "+selectedMonthName);
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ANT83Gvt0hoS_SG-4erojBELObeNFnXhks5uX43KgaJpZM4WaVpq>
.