Java tutorial
//package com.java2s; import java.util.Calendar; public class Main { public static boolean isOver18(int year, int month, int day) { Calendar cal = Calendar.getInstance(); int months = (cal.get(Calendar.YEAR) - year) * 12; months += cal.get(Calendar.MONTH) - month; int age = months / 12; if (age < 18 || (age == 18 && day > cal.get(Calendar.DAY_OF_MONTH))) { return false; } return true; } }