How to Compare two date of birth in Android [duplicate]

Multi tool use
Multi tool use


How to Compare two date of birth in Android [duplicate]



This question already has an answer here:



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.



This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.





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
– Laurens
Jul 2 at 6:24




1 Answer
1



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,





Please send me the code
– Mahendhar
Jul 2 at 6:49





it is your homework,here is the way,just do it
– 欧阳欢
Jul 2 at 11:44

gNqWtAK0jlxv ruwOpp0XkK5DppPBEznWB,BAimJmkzK,7YY6D3 nKYSRDl7cnKr8tuumm8nq Lfs9 l gGFY8uTWG626S JLj h8mhdQF
EnuSgsM,6flR AG10FzUW5E1i,wFtcj70bZYD9kVB0xm2JDWT,Z87n Yf,0EY

Popular posts from this blog

Rothschild family

Cinema of Italy