Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 918
Harsha M V Avatar asked Oct 29 '11 17:10

Harsha M V


1 Answers

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].

like image 100
Yashwanth Kumar Avatar answered Oct 03 '22 18:10

Yashwanth Kumar