Java tutorial
//package com.java2s; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static String getCurrentAgeByBirthdate(String brithday) { SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd"); java.util.Date date = new Date(); java.util.Date mydate = null; try { mydate = myFormatter.parse(brithday); } catch (ParseException e) { e.printStackTrace(); } long day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000) + 1; String year = new java.text.DecimalFormat("#").format(day / 365f); return year; } }