title: Check user is greater than 18 years from todays date with date picker android
body: <p>I am trying to check that my user should be 18 years old. If Not then show a toast. (Trying to get from exact today date). But result is getting success only year wise.</p>
  
  <p>Output - Years are getting calculated.
  Expected  -  From today's date, user should be 18 years old.</p>
  
  <p>this is what i have tried.</p>
  
  <pre><code>    val calendar = Calendar.getInstance()
      val year = calendar.get(Calendar.YEAR)
      val month = calendar.get(Calendar.MONTH)
      val day = calendar.get(Calendar.DAY_OF_MONTH)
      val dpd = DatePickerDialog(this, DatePickerDialog.OnDateSetListener { view, year, monthOfYear, dayOfMonth -&gt;
              calendar.set(Calendar.YEAR, year)
              calendar.set(Calendar.MONTH, monthOfYear)
              calendar.set(Calendar.DAY_OF_MONTH, dayOfMonth)
              val sdf = SimpleDateFormat(myFormat, Locale.US)
              val dob = sdf.format(calendar.time)
  
              val userAge = GregorianCalendar(year, month, day)
              val minAdultAge = GregorianCalendar()
              minAdultAge.add(Calendar.YEAR, -18)
              minAdultAge.add(Calendar.MONTH, -1)
              if (minAdultAge.before(userAge)) {
                  Toast.makeText(this, getString(R.string.txt_18_years_age_validation), Toast.LENGTH_SHORT).show()
              } else {
                  etDob!!.setText(dob)
              }
          }, year, month, day
      )
  
      dpd.datePicker.maxDate = Calendar.getInstance().timeInMillis
      dpd.show()
  </code></pre>
  
  <p>What modifications needed to get validations for todays date.</p>
  
  <p>Thank You.</p>