Java date: calculate age | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

Java date: calculate age

How can calculate my age in years,month,weeks,days,hour,second in Java code?

2nd Aug 2019, 9:37 PM
Ali Mustafa
Ali Mustafa - avatar
1 Antwort
+ 5
Basically you create two LocalDateTime objects, one for now and one for the birth datetime. You can calculate the period between two LocalDateTimes with ChronoUnit.
3rd Feb 2020, 5:25 PM
Tashi N
Tashi N - avatar