+ 1

Calculation in object oriented program

display name & age

12th Sep 2017, 11:25 AM
Babu Raju
Babu Raju - avatar
3 Réponses
+ 4
😂 right @luca
12th Sep 2017, 11:37 AM
Boo
Boo - avatar
+ 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);
12th Sep 2017, 11:31 AM
MsJ
MsJ - avatar