Avatar of Farzad Akbarnejad
Farzad Akbarnejad
Flag for Iran, Islamic Republic of asked on

Check for greater than 15 years old.

Hello,
I have a birthDate as Date data type and I want to check if person age is greater than 15 years old now. How can I code it?

Thanks
-FA
Java

Avatar of undefined
Last Comment
Farzad Akbarnejad

8/22/2022 - Mon
CEHJ

ASKER CERTIFIED SOLUTION
Mick Barry

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Farzad Akbarnejad

ASKER
Hi,
I found the following code. It is as same as object code:

                    java.util.Calendar c1 = java.util.Calendar.getInstance();
                    c1.setTime(new java.util.Date());
                    c1.add(java.util.Calendar.YEAR, -15);
                    if (d.getBirthDate().getTime() < c1.getTime().getTime()) {
                        // Age is greater than 15.
                    }
Thanks for your help.
-FA

Your help has saved me hundreds of hours of internet surfing.
fblack61