Here you can find the source of getBeginOfDay(Date date)
Parameter | Description |
---|---|
date | a parameter |
public static Date getBeginOfDay(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 final String LONG_DATE_FORMAT_STR = "yyyy-MM-dd HH:mm:ss"; public static final String EARER_IN_THE_DAY = "yyyy-MM-dd 00:00:00.000"; /**// w ww .j av a 2s . c o m * @param date * @return Date */ public static Date getBeginOfDay(Date date) { String beginDay = new SimpleDateFormat(EARER_IN_THE_DAY).format(date); try { return parserStringToDate(beginDay, LONG_DATE_FORMAT_STR); } catch (ParseException e) { } return null; } /** * @param dateString * @param format * @return Date * @throws ParseException */ public static Date parserStringToDate(String dateString, String format) throws ParseException { DateFormat dateFormat = new SimpleDateFormat(format); return dateFormat.parse(dateString); } /** * @param dateString * @param format * @return Date */ public static Date parse(String dateString, String format) { Date date = null; try { date = parserStringToDate(dateString, format); } catch (Exception e) { } return date; } }