Java Age Calculate getAge(String year)

Here you can find the source of getAge(String year)

Description

get Age

License

Apache License

Declaration

public static Integer getAge(String year) 

Method Source Code

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

import java.util.Calendar;

public class Main {

    public static Integer getAge(String year) {
        Calendar c = Calendar.getInstance();
        if (year == null) {
            return 20;
        }//w w w .ja  va 2  s. c  o  m
        year = year.substring(0, 4);
        Integer age = c.get(Calendar.YEAR) - Integer.parseInt(year);
        return age;
    }
}

Related

  1. getAge(Date date)
  2. getAge(Date date, TimeZone tz)
  3. getAge(Date dateNaissance)
  4. getAge(Date time, Date birth)
  5. getAge(final Date birthDay, final Date currDate)
  6. getAge1(Date birthDay)
  7. getAgeAt(final Date birthday, final Date date)
  8. getAgeFromBirthDate(Date birth, boolean estimate)
  9. getAgeFromBirthday(Date birthday)