Reputation: 235
I want to customize this display day, Date and Month format in EEEE d, MMMM Format.
Thanks in Advance.
Upvotes: 1
Views: 1074
Reputation: 508
It's fully logical. You can try this
public static class EndDatePickerFragment extends DialogFragment
implements DatePickerDialog.OnDateSetListener {
public AdvancedSearchFragment instant;
public int dd = 0, mm, yyyy;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
if (dd == 0) {
final Calendar c = Calendar.getInstance();
yyyy = c.get(Calendar.YEAR);
mm = c.get(Calendar.MONTH);
dd = c.get(Calendar.DAY_OF_MONTH);
}
DatePickerDialog dpd = new DatePickerDialog(getActivity(), this, yyyy, mm, dd);
// Added all possible null conditions
((TextView)((LinearLayout)((LinearLayout)((LinearLayout)((DatePicker)dpd.getDatePicker()).getChildAt(0)).getChildAt(0)).getChildAt(0)).getChildAt(1)).setText("My Date");
return dpd;
}
public void onDateSet(DatePicker view, int year, int month, int day) {
// Do something with the date chosen by the user
instant.doSetEndTime(year, month + 1, day);
}
}
This below line will set the value of Fri, Oct 13
((TextView)((LinearLayout)((LinearLayout)((LinearLayout)((DatePicker)dpd.getDatePicker()).getChildAt(0)).getChildAt(0)).getChildAt(0)).getChildAt(1)).setText("My Date");
If you want to change the format of year 2017 then use below
((TextView)((LinearLayout)((LinearLayout)((LinearLayout)((DatePicker)dpd.getDatePicker()).getChildAt(0)).getChildAt(0)).getChildAt(0)).getChildAt(0)).setText("My Year");
So in place of My Date you can use date format & set the date as you want.
I hope this will help!
Upvotes: 1