Question: I want to convert date of birth into age.
This is my code.

```html
String patientDOB = driver.findElement(id("patient_profile_widget_form_birthday")).getAttribute("value");
```

I'm getting date as: 03/01/1961 

How could I convert this into age? 
I want output like => 57 Years

Any idea? :)

Answer: 
using java 8

```
public int calculateAge(
  LocalDate birthDate) {
    // validate inputs ...
    return Period.between(birthDate, LocalDate.now());
}

```
Create a wrapper method that get you string as argument,

use:

```
 String[] parts = string.split("/"); 

```

and select the 3rd item of the list.

then you just have to use:

```
int year = Calendar.getInstance().get(Calendar.YEAR);

```

to get your year. Then you just convert your year string into an int and substract them