Problem
Complete the apex method to calculate the age based on date of birth. The given apex method accepts a date input parameter. Find the age for a person based on date of birth.
Instructions
- The method must accept a date parameter, the date of birth of a person.
- Calculate the age based on today's date.
- Return the age as a integer number in response.
Sample output
Input date is 01/01/1980
Today is : 02/01/2020
Integer age = ageController.calculateAge(dateOfBirth);
The age is 40
Note: Date is one of the primitive data types in apex. Apex provides a set of built in functions to operate on dates. See the official documentation for apex date methods and utilize them to solve this scenario.