Here you can find the source of getAge(Date birthday)
private static float getAge(Date birthday)
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Date; public class Main { private static float getAge(Date birthday) { Calendar calendar = Calendar.getInstance(); int yearNow = calendar.get(Calendar.YEAR); int monthNow = calendar.get(Calendar.MONTH); calendar.setTime(birthday);//from w ww . j av a 2s . c om int yearBorn = calendar.get(Calendar.YEAR); int monthBorn = calendar.get(Calendar.MONTH); int year = yearNow - yearBorn; if (year >= 1) return year; int month = monthNow - monthBorn; if (month > 0 && month < 1) month = 1; return month / 12.0F; } }