Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Calendar; public class Main { public static boolean isDateInCurrentYear(long date) { Calendar currentCalendar = getCurrentCalendar(); int year = currentCalendar.get(Calendar.YEAR); Calendar targetCalendar = getCalendarWithTime(date); int targetYear = targetCalendar.get(Calendar.YEAR); return (year == targetYear); } public static Calendar getCurrentCalendar() { return getCalendarWithTime(System.currentTimeMillis()); } public static Calendar getCalendarWithTime(long time) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time); return calendar; } }