Android examples for java.util:Calendar
is a Calendar Before another Calendar
//package com.java2s; import android.util.Log; import java.util.Calendar; public class Main { public static boolean isBefore(Calendar currentCalendar, Calendar max) { int currentYear = currentCalendar.get(Calendar.YEAR); int currentMonth = currentCalendar.get(Calendar.MONTH); int currentDay = currentCalendar.get(Calendar.DAY_OF_MONTH); int maxYear = max.get(Calendar.YEAR); int maxMonth = max.get(Calendar.MONTH); int maxDay = max.get(Calendar.DAY_OF_MONTH); return (currentYear == maxYear) ? ((currentMonth == currentMonth) ? (currentDay < maxDay) : (currentMonth < maxMonth)) : (currentYear < maxYear); }/* w w w.j a va2 s .c o m*/ }