Datepicker Shows Wrong Value of Month

After selecting date, its showing wrong month

In this case, the month count is started at 0. So you have to add 1 for display.

  editStartDate.setText(selectedday + "/" + (selectedmonth + 1) + "/" + selectedyear);

See also this question for reference: Why is January month 0 in Java Calendar?

DatePicker showing month value starting from 0

According to developer.android.com month ranges from 0-11.

So you need to increment it by 1.

public void onDateSet(DatePicker view, int year, int month, int day) {
int selectedMonth = month+1;
cval_to.setText(day + "/" + selectedMonth + "/" + year);
}


Related Topics



Leave a reply



Submit