I would like to calculate the age by taking the date of birth from the database, using pojo
.
I was looking at how to do a date calculation by looking at this question: Calculate age by day, month, and year
My date in the database is as DATE
, so I could not convert to be able to compare with localDate, this error results:
(Incompatible types: Date can not be converted to LocalDate)
I was trying to do this:
public int idade() {
return Period.between(meuPojo.getDataNascimento(), LocalDate.now()).getYears();
}
My pojo method that takes the date ( getDataNascimento()
) is of type java.util.Date
;
How do I do this conversion?