I'm trying to validate a EditText field that should have the format of DD/MM/YYYY date. I tried the following code but it is not giving me the correct answer:
val dateFormat = "/d{2}(/)/d{2}(/)/d{4}"
val pattern: Pattern = Pattern.compile(dateFormat)
val matcher: Matcher = pattern.matcher(editDate.text.toString())
if (matcher.find()) {
Log.i("Date","DATE matched! " + editDate.text.toString())
super.onBackPressed()
} else {
editDate.error = "Date format incorrect!"
Log.i("Date","DATE NOT matched! " + editDate.text.toString())
}