+ 1
Calculation in object oriented program
display name & age
3 Réponses
+ 4
😂 right @luca
+ 3
public int getAge()
{
long ageInMillis = new Date().getTime() - getBirthDate().getTime();
Date age = new Date(ageInMillis);
return age.getYear();
}
or you can do like that
LocalDate birthdate = new LocalDate (1970, 1, 20); LocalDate now = new LocalDate();
Years age = Years.yearsBetween(birthdate, now);