Here you can find the source of isInCurrentYear(long lTime)
public static boolean isInCurrentYear(long lTime)
//package com.java2s; import java.util.Calendar; public class Main { public static boolean isInCurrentYear(long lTime) { Calendar cal = Calendar.getInstance(); Calendar calUnknown = Calendar.getInstance(); cal.setTimeInMillis(System.currentTimeMillis()); calUnknown.setTimeInMillis(lTime); int nDayOfYear = cal.get(Calendar.DAY_OF_YEAR); cal.add(Calendar.DAY_OF_YEAR, 0 - nDayOfYear); if (calUnknown.before(cal)) { return false; }//from w ww .j av a 2s . co m cal.add(Calendar.DAY_OF_YEAR, 365); if (calUnknown.after(cal)) { return false; } return true; } }