Here you can find the source of getDateByDay(Date date)
public static List<Date> getDateByDay(Date date)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static List<Date> getDateByDay(Date date) { List<Date> dates = new ArrayList<>(); Calendar c = GregorianCalendar.getInstance(); c.setTime(date);//from w w w .j a v a2s . c o m setTimeToBeginningOfDay(c); dates.add(c.getTime()); setTimeToEndofDay(c); dates.add(c.getTime()); return dates; } public static List<Date> getDateByDay() { List<Date> dates = new ArrayList<>(); Calendar c = GregorianCalendar.getInstance(); setTimeToBeginningOfDay(c); dates.add(c.getTime()); setTimeToEndofDay(c); dates.add(c.getTime()); return dates; } private static void setTimeToBeginningOfDay(Calendar calendar) { calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); } private static void setTimeToEndofDay(Calendar calendar) { calendar.set(Calendar.HOUR_OF_DAY, 23); calendar.set(Calendar.MINUTE, 59); calendar.set(Calendar.SECOND, 59); calendar.set(Calendar.MILLISECOND, 999); } }