0

Checkin and checkout date pickers, For example if person is checking in today, the dates on the past days are blocked off, and for the checkout date picker I want the start date to be after the selected checkin date.

//check-in and check-out values
@SuppressLint("SimpleDateFormat")
val checkIndatePickerDialogListener = DatePickerDialog.OnDateSetListener{ _, year, month, day->
    val myCalender = Calendar.getInstance()
    myCalender.set(Calendar.YEAR,year)
    myCalender.set(Calendar.MONTH,month)
    myCalender.set(Calendar.DAY_OF_MONTH,day)
    val dateFormat = SimpleDateFormat("yyyy-MM-dd")
    checkin.setText(dateFormat.format(myCalender.time))

}

@SuppressLint("SimpleDateFormat")
val checkOutdatePickerDialogListener = DatePickerDialog.OnDateSetListener{ _, year, month, day->
    val myCalender = Calendar.getInstance()
    myCalender.set(Calendar.YEAR,year)
    myCalender.set(Calendar.MONTH,month)
    myCalender.set(Calendar.DAY_OF_MONTH,day+1)
    val dateFormat = SimpleDateFormat("yyyy-MM-dd")
    checkout.setText(dateFormat.format(myCalender.time))
}

Can anyone help?

Codexers
  • 3
  • 2

0 Answers0