Java tutorial
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static boolean isSameYear(Date targetTime, Date compareTime) { Calendar tarCalendar = Calendar.getInstance(); tarCalendar.setTime(targetTime); int tarYear = tarCalendar.get(Calendar.YEAR); Calendar compareCalendar = Calendar.getInstance(); compareCalendar.setTime(compareTime); int comYear = compareCalendar.get(Calendar.YEAR); return tarYear == comYear; } }