Harsha M V Harsha M V - 1 year ago 106
Android Question

Android DatePicker display Month name

I am trying use Date Picker and on Select i want to display the date in the following format

[Month name] [date], [year]

final Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR)-13;
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);

that gives Month as a number. How to get the name of the month instead of number.

Answer Source
public static final String[] MONTHS = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};

use an array and get the String by MONTHS[monthNumber].

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download