Mykhailo Granik
Mykhailo Granik

Reputation: 378

Display month name in DatePicker

In my app I am using calendar view of DatePicker, but it doesn't display name of current month. I think it is not very convenient for user. Is there a way to display month name?

Upvotes: 1

Views: 3182

Answers (2)

Darko Petkovski
Darko Petkovski

Reputation: 3912

You can do something like this:

DatePicker datepicker=new DatePicker();
int month=date.getMonth();
public static final String[] MONTHS = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
String mon=MONTHS[month];

Hope this helps!

Upvotes: 2

Linga
Linga

Reputation: 10553

Try something like this

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

and use the mon

Upvotes: 2

Related Questions