Java tutorial
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static boolean isTheDay(final Date date, final Date day) { return date.getTime() >= dayBegin(day).getTime() && date.getTime() <= dayEnd(day).getTime(); } public static Date dayBegin(final Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); c.set(Calendar.HOUR_OF_DAY, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MILLISECOND, 0); return c.getTime(); } public static Date dayEnd(final Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); c.set(Calendar.HOUR_OF_DAY, 23); c.set(Calendar.MINUTE, 59); c.set(Calendar.SECOND, 59); c.set(Calendar.MILLISECOND, 999); return c.getTime(); } }