Java tutorial
//package com.java2s; //License from project: Apache License 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); Log.i("TAG", (currentYear <= maxYear && currentMonth <= maxMonth && currentDay <= maxDay) + "currentYear" + currentYear + "maxYear" + maxYear + "currentMonth" + currentMonth + "maxMonth" + maxMonth + "currentDay" + currentDay + "maxDay" + maxDay); return (currentYear == maxYear) ? ((currentMonth == currentMonth) ? (currentDay < maxDay) : (currentMonth < maxMonth)) : (currentYear < maxYear); } }