How to do date validation? [closed]

2

How do I validate the date as the date of birth? Not being able to put the date in the future.

        data.addTextChangedListener(DateUtils.insert("##/##/####", data));


                 mData = data.getText().toString();
    
asked by anonymous 17.07.2017 / 23:08

1 answer

0

You can try something like this:

String dataDigitadaStr = editText.getText().toString(); // Ex: "04/05/2010"

SimpleDateFormat formater = new SimpleDateFormat("dd/MM/yyyy"); 
Date dataDigitada= formater.parse(dataDigitadaStr); 

if(dataDigitada.getTime() >= Date.now()){
   Toast.makeText(this, "Data digitada maior que a data atual", Toast.LENGTH_SHORT).show();
}
    
17.07.2017 / 23:46