Android examples for java.util:Year
Is date value in long value the current year
import android.text.TextUtils; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; public class Main{ public static boolean checkCurrentYear(long time) { Calendar c = Calendar.getInstance(); c = Calendar.getInstance(tz); c.setTimeInMillis(time);/* w ww. j a v a 2 s . c o m*/ long currentTime = System.currentTimeMillis(); Calendar current_c = Calendar.getInstance(); current_c = Calendar.getInstance(tz); current_c.setTimeInMillis(currentTime); int currentYear = current_c.get(Calendar.YEAR); int y = c.get(Calendar.YEAR); return y == currentYear; } }