Set language to French in android DatePickerDialog

I made it!

I have added these 2 lines before all the DatePickerDialog stuff:

Locale locale = getResources().getConfiguration().locale;
Locale.setDefault(locale);

and after that:

Calendar c = Calendar.getInstance();
int mYear = c.get(Calendar.YEAR);
int mMonth = c.get(Calendar.MONTH);
int mDay = c.get(Calendar.DAY_OF_MONTH);
DatePickerDialog dialog = new DatePickerDialog(MainActivity.this,
            this, mYear, mMonth, mDay);
dialog.getDatePicker().setMaxDate(c.getTimeInMillis());
dialog.setTitle(R.string.main_first_day_of_your_last_period);
dialog.show();

I hope it helps someone.

Leave a Comment