Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java age from date

LocalDate today = LocalDate.now();
LocalDate birthday = LocalDate.of(1987, 09, 24);

Period period = Period.between(birthday, today);

//Now access the values as below
System.out.println(period.getDays());
System.out.println(period.getMonths());
System.out.println(period.getYears());
Comment

calculate age from localdate java

public int calculateAge(
  LocalDate birthDate,
  LocalDate currentDate) {
    // validate inputs ...
    return Period.between(birthDate, currentDate).getYears();
}
Comment

PREVIOUS NEXT
Code Example
Java :: firestore add to field array 
Java :: print line number java 
Java :: separate string by comma java 
Java :: system.out.write in java example 
Java :: how to iterate hashmap in java 
Java :: java array contains 
Java :: how to read from a txt file in java 
Java :: sum of array recursion java 
Java :: RealmConfiguration.Builder.allowWritesOnUiThread(true) 
Java :: How to generate all subsets of a given set in Java? 
Java :: glide dependency android java 
Java :: java event enter key 
Java :: java loop backwards through array 
Java :: java eliminate numbers from string 
Java :: String array into LinkedList java 
Java :: java get current date 
Java :: converter int array para string java 
Java :: find shortest string in array java 
Java :: How to convert timestamp to time in android studio 
Java :: parallel sorting in java 8 
Java :: system.out.println shortcut 
Java :: java 8 group a collections by 2 property 
Java :: jackson localdate 
Java :: java random char 
Java :: calendar java add 1 day 
Java :: java scanner input float 
Java :: prime number between given range in java 
Java :: setbounds in java 
Java :: autowire and qualifier 
Java :: read integer input java 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =