Reputation: 2052
DatePickerDialog
display M01
instead of January
for example...
This is my code:
@OnClick(R.id.dateTextView)
public void onDateTextViewClick(View view) {
DatePickerDialog dialog = new DatePickerDialog(this,
mDateListener, mYear, mMonth, mDay);
dialog.getDatePicker().setMaxDate(mCalendar.getTimeInMillis());
dialog.show();
}
private DatePickerDialog.OnDateSetListener mDateListener = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker arg0, int arg1, int arg2, int arg3) {
// TODO Auto-generated method stub
mYear = arg1;
mMonth = arg2;
mDay = arg3;
showDate();
}
};
How can I change it?
Upvotes: 2
Views: 1002
Reputation: 3217
You wrongly set your local value. Something like this
// Don't copy past this
Locale locale = new Locale("","");
Locale.setDefault(locale);
Instead use proper language code and country code. eg:-
Locale locale = new Locale("en","GB");
Locale.setDefault(locale);
Upvotes: 2
Reputation: 703
public void getDate(EditText editText) {
Calendar c = Calendar.getInstance(Locale.getDefault());
int mYear = c.get(Calendar.YEAR);
int mMonth = c.get(Calendar.MONTH);
int mDay = c.get(Calendar.DAY_OF_MONTH);
// date picker dialog
datePickerDialog = new DatePickerDialog(CustomerProfileActivity.this,
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
selectedDate = year + "-" + (monthOfYear + 1) + "-" + dayOfMonth;
editText.setText(selectedDate);
}
}, mYear, mMonth, mDay);
datePickerDialog.getDatePicker().setMaxDate(System.currentTimeMillis() - 1000);
datePickerDialog.setTitle("Select Date");
datePickerDialog.show();
}
Just pass "Locale.getDefault()" in Calendar.getInstance
Upvotes: 0
Reputation: 1271
Just pass month no and you will get Month Name
public String getMonth(int month) {
return new DateFormatSymbols().getMonths()[month-1];
}
Upvotes: 0