Here you can find the source of getDayBegin(Date date)
public static Date getDayBegin(Date date)
//package com.java2s; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static Date getDayBegin(Date date) { DateFormat df = new SimpleDateFormat("yyyyMMdd"); df.setLenient(false);/*from w ww .j a v a 2 s . c o m*/ String dateString = df.format(date); try { return df.parse(dateString); } catch (ParseException e) { return null; } } public static String format(Date date, String format) { if (date == null) { return null; } return new SimpleDateFormat(format).format(date); } }