I'm using datepicker, but whenever I'm selecting any date its showing -1 moneth. For example- If I select 12/12/2016, it'll display in textbox 12/11/2016 If I select 3/1/2017, it'll display 3/0/2017
Here is my piece of code of datepicker dialog:
editStartDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Calendar mcurrentDate = Calendar.getInstance();
int mYear = mcurrentDate.get(Calendar.YEAR);
int mMonth = mcurrentDate.get(Calendar.MONTH);
int mDay = mcurrentDate.get(Calendar.DAY_OF_MONTH);
DatePickerDialog mDatePicker = new DatePickerDialog(TourActivity.this, new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) {
Calendar newDate = Calendar.getInstance();
newDate.set(selectedyear, selectedmonth, selectedday);
editStartDate.setText(selectedday + "/" + selectedmonth + "/" + selectedyear);
}
}, mYear, mMonth, mDay);
mDatePicker.setTitle("Select date");
mDatePicker.show();
}
});
Please suggest where I'm putting wrong code.