Here you can find the source of getAge(String year)
public static Integer getAge(String year)
//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; } }