Reputation: 41
I am building an android application where a user select the date using date picker tool.
The format of the date I get is 20 12 2014 and I need the format 20 December 2014.
Here is my code :
public class DatePickerFragment extends DialogFragment implements
DatePickerDialog.OnDateSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceSateate) {
final Calendar c = Calendar.getInstance();
int year = c.get(Calendar.YEAR);
int month = c.get(Calendar.MONTH);
int day = c.get(Calendar.DAY_OF_MONTH);
return new DatePickerDialog(getActivity(), this, year, month, day);
}
public void onDateSet(DatePicker view, int year, int month, int day) {
// Do something with the date chosen
//tdate.setText((month));
tdate.setText(day + " " + (month + 1) + " " + year);
//date = tdate.getText().toString();
}
}
Upvotes: 1
Views: 96
Reputation: 2729
public void updateDate(int year, int monthOfYear, int dayOfMonth) {
if (mYear != year || mMonth != monthOfYear || mDay != dayOfMonth) {
mYear = year;
mMonth = monthOfYear;
mDay = dayOfMonth;
updateSpinners();
//HERE
reorderPickers(new DateFormatSymbols().getShortMonths());
notifyDateChanged();
}
}
Upvotes: 1