-1

I have two edit texts first one is date of birth(datepicker) second one is till today(datepicker).

In that I want to compare both the date of birth.

and I have one button named as Save

when the two date of births are 18 years old or above then only it shows the toast msg saved successfully otherwise it shows Age must be 18 or above

I hope you understand the question. Thank you advance.

Mahendhar
  • 7
  • 5
  • What have you tried so far? You can cast the result of the datepickers to a Date object and simply subtract them, check if it returns at least 18 years and you're good to go – DGK Jul 02 '18 at 06:24

1 Answers1

0

The default end time is larger than the start time. The year of today's year is subtracted from the birthday. If the result is greater than 18 or less than 18, direct processing. If the result is 18, the month and the day are subtracted,

欧阳欢
  • 1
  • 2