I kinda stuck with this problem.
I have created a DatePickerDialog in a fragment. I set the default date to be the current date when the user is opening the calendar for the first time. When the dialog is dismissed, I'm setting the EditText with the date the user have chosen.
But when the user opens the date picker dialog again, it stays at the default date. I want when the user opens the dialog again to show latest selected date. What would be the best approach to this problem?

The DatePickerFragment file:

```kotlin

    class DatePickerFragment : DialogFragment(),
        DatePickerDialog.OnDateSetListener {

        override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
            val c = Calendar.getInstance()
            val year = c.get(Calendar.YEAR)
            val month = c.get(Calendar.MONTH)
            val day = c.get(Calendar.DAY_OF_MONTH)
            val datePickerDialog = DatePickerDialog(requireContext(), this, year, month, day)
            datePickerDialog.datePicker.maxDate = c.timeInMillis
            return datePickerDialog
        }

        override fun onDateSet(view: DatePicker?, year: Int, month: Int, dayOfMonth: Int) {
            val date = DateUtils.formatToBirthdayString(year, month, dayOfMonth)
            parentFragmentManager.setFragmentResult(
                KEY_BIRTH_DATE,
                Bundle().apply { putString(KEY_BIRTH_DATE, date) }
            )
        }
    }

```

BirthdayDialogCommand file:

```kotlin
class BirthdayDialogCommand(private val fragmentManager: FragmentManager) : Command {

    override fun execute() {
        val picker = DatePickerFragment()

        if (fragmentManager.findFragmentByTag(BirthdayDialogCommand::class.java.simpleName) == null) {
            picker.show(fragmentManager, BirthdayDialogCommand::class.java.simpleName)
        }
    }
}

```

And the DetailsFragment file:

```kotlin
    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View {

        ................................

        setDataBinding()
        setDataListeners()

        return binding.root
    }

    private fun setDataBinding() {
        binding.apply {

            ................................

            birthdayCommand = BirthdayDialogCommand(
                parentFragmentManager
            )
    }

    private fun setDataListeners() {

        ................................

        parentFragmentManager.setFragmentResultListener(
            KEY_BIRTH_DATE,
            viewLifecycleOwner,
            patientDataListener
        )

    }

 private val patientDataListener = FragmentResultListener { _, bundle ->
        bundle.getString(KEY_BIRTH_DATE)?.let {
            binding.birthday.text = it
            patientViewModel.setPatientBirthday(it)
        }

        ................................
    }

```