Java, How to calculate a persons age
// Create a calendar object with the date of birth
Calendar dateOfBirth = new GregorianCalendar(1972, Calendar.JANUARY, 15);
// Create a calendar object with today's date
Calendar today = Calendar.getInstance();
// Get age based on year
int age = today.get(Calendar.YEAR) - dateOfBirth.get(Calendar.YEAR);
Log in to answer.
Copyright © dBuggr.com - All Rights Reserved.