Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Calendar; import java.util.Locale; public class Main { public static boolean hasMonthPassed(int year, int month) { Calendar now = Calendar.getInstance(); // Expires at end of specified month, Calendar month starts at 0 return hasYearPassed(year) || normalizeYear(year) == now.get(Calendar.YEAR) && month < (now.get(Calendar.MONTH) + 1); } public static boolean hasYearPassed(int year) { int normalized = normalizeYear(year); Calendar now = Calendar.getInstance(); return normalized < now.get(Calendar.YEAR); } private static int normalizeYear(int year) { if (year < 100 && year >= 0) { Calendar now = Calendar.getInstance(); String currentYear = String.valueOf(now.get(Calendar.YEAR)); String prefix = currentYear.substring(0, currentYear.length() - 2); year = Integer.parseInt(String.format(Locale.US, "%s%02d", prefix, year)); } return year; } }