title: How to set mindate datepicker in fragment kotlin?
body: <p>I need help to set min date in a datepicker. The example shows today in the datepicker and should disable picking yesterday or earlier:</p>
  <pre><code>     &lt;EditText
              android:id=&quot;@+id/etDates2&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_margin=&quot;16dp&quot;
              android:background=&quot;@drawable/et_style&quot;
              android:padding=&quot;12dp&quot;
              android:hint=&quot;@string/date&quot;
              android:drawableStart=&quot;@drawable/et_calendar3&quot;
              android:drawablePadding=&quot;12dp&quot;
              android:inputType=&quot;date&quot;
              android:focusable=&quot;false&quot;
              android:textStyle=&quot;bold&quot;
              android:textSize=&quot;15.3dp&quot;
              android:fontFamily=&quot;@font/poppins_regular&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;parent&quot; /&gt;
  </code></pre>
  <p>and datefragment.kt like this below:</p>
  <pre><code>import android.app.DatePickerDialog
  import android.app.Dialog
  import android.os.Bundle
  import android.widget.DatePicker
  import androidx.fragment.app.DialogFragment
  import com.greenhcm.android.common.function.toDateFormat
  import com.greenhcm.android.common.function.toTimeMilis
  import java.util.*
  
  class DatePickerFragments : DialogFragment(), DatePickerDialog.OnDateSetListener {
  
      private lateinit var action : (String) -&gt; Unit
      private var maxDate : String? = null
      private var minDate : String? = null
  
      override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
          // Use the current date as the default date in the picker
          val c = Calendar.getInstance()
          val year = c.get(Calendar.YEAR)
          val month = c.get(Calendar.MONTH)
          val day = c.get(Calendar.DAY_OF_MONTH)
  
          // Create a new instance of DatePickerDialog and return it
          return DatePickerDialog(requireContext(), this, year, month, day).apply {
              maxDate?.takeIf { it.isNotEmpty() }?.let {
                  datePicker.maxDate = it.toTimeMilis(&quot;yyyy-MM-dd&quot;)
              }
              minDate?.takeIf { it.isNotEmpty() }?.let {
                  datePicker.minDate = it.toTimeMilis(&quot;yyyy-MM-dd&quot;)
              }
          }
      }
  
      override fun onDateSet(view: DatePicker, year: Int, month: Int, day: Int) {
          action(&quot;$year-${month+1}-$day&quot;)
      }
  
      fun setListener(
          maxDate: String? = null,
          minDate: String? = null,
          action: (String) -&gt; Unit
      ) {
          this.action = action
          this.maxDate = maxDate
          this.minDate = minDate
      }
  }
  </code></pre>
  <p>I am confused here. How to set mindate in datepicker here? Call from other fragments?</p>
  <pre><code>    etDates2.setOnClickListener {
              val newFragment = DatePickerFragment().apply {
                  setListener {
                      setDate(it)
                  }
              }
              newFragment.show(childFragmentManager, &quot;timePickers&quot;)
          }
  </code></pre>
  <p>Parameter setDate :</p>
  <pre><code>private fun setDate(date: String){
      etDates2?.setText(date)
  }
  </code></pre>