Here you can find the source of isInDate(Date date, Date compareDate)
public static boolean isInDate(Date date, Date compareDate)
//package com.java2s; //License from project: Apache License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; public class Main { public static SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); public static SimpleDateFormat format1 = new SimpleDateFormat("yyyyMMdd HH:mm:ss"); public static boolean isInDate(Date date, Date compareDate) { if (compareDate.after(getStartDate(date)) && compareDate.before(getFinallyDate(date))) { return true; } else {/* w w w . j a va 2 s . c o m*/ return false; } } public static Date getStartDate(Date date) { String temp = format.format(date); temp += " 00:00:00"; try { return format1.parse(temp); } catch (Exception e) { return null; } } public static Date getFinallyDate(Date date) { String temp = format.format(date); temp += " 23:59:59"; try { return format1.parse(temp); } catch (ParseException e) { return null; } } public static Date parse(Long time) { if (time == null) { return null; } Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(time); return cal.getTime(); } public static String getTime(String pattern) { return new SimpleDateFormat(pattern).format(new Date()); } }