Here you can find the source of isDateInRange(Date toCheck, Date minRange, Date maxRange)
public static boolean isDateInRange(Date toCheck, Date minRange, Date maxRange)
//package com.java2s; //License from project: Open Source License import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.*; public class Main { public static boolean isDateInRange(Date toCheck, Date minRange, Date maxRange) {/* w ww.java 2s.c o m*/ String toCheckStr = formatYmd(toCheck); return ((minRange == null || toCheckStr .compareTo(formatYmd(minRange)) >= 0) && (maxRange == null || toCheckStr .compareTo(formatYmd(maxRange)) <= 0)); } /** * Utility method to format a date in yyyy-MM-dd format * @param d the date to format * @return a String representing the date in the passed format */ public static String formatYmd(Date d) { return formatDate(d, "yyyy-MM-dd", ""); } /** * Utility method to format a date in the given format * @param d the date to format * @return a String representing the date in the passed format */ public static String formatDate(Date d, String format) { return formatDate(d, format, ""); } /** * Utility method to format a date in the given format * @param d the date to format * @param format the DateFormat to use * @param defaultIfNUll the value to return if the passed date is null * @return a String representing the date in the passed format */ public static String formatDate(Date d, String format, String defaultIfNull) { if (d != null) { DateFormat df = new SimpleDateFormat(format); return df.format(d); } return defaultIfNull; } }