Java Age Calculate calculateAge(Date birthday)

Here you can find the source of calculateAge(Date birthday)

Description

calculate Age

License

Apache License

Declaration

public static int calculateAge(Date birthday) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.Calendar;
import java.util.Date;

public class Main {
    public static int calculateAge(Date birthday) {
        Calendar today = Calendar.getInstance();
        Calendar birth = Calendar.getInstance();
        birth.setTime(birthday);/* w  w  w  . j  a  v a  2 s.  com*/
        int todayYear = today.get(Calendar.YEAR);
        int birthYear = birth.get(Calendar.YEAR);
        return todayYear - birthYear;
    }
}

Related

  1. ageAcceptable(final Date doB, final Date now, final int acceptedAge)
  2. ageInYears(java.util.Date dateUtil)
  3. calculateAge(Date aBirthdate)
  4. calculateAge(Date aDateFrom, Date aDateTo)
  5. calculateAge(Date birthDate)
  6. calculateAge(Date dateOfBirth)
  7. calculateAge(Date dob)
  8. calculateAge(Date DOB)
  9. calculateAgeInMonth(final Date birthDate, final Date asOfDate)