Here you can find the source of getStartOfDay(Date dateToFormat)
Parameter | Description |
---|---|
dateToFormat | Date to be formatted, cannot be null. |
public static Date getStartOfDay(Date dateToFormat)
//package com.java2s; //License from project: Open Source License import java.time.LocalDate; import java.time.ZoneId; import java.util.Date; public class Main { /**/*from w w w . j av a 2 s . co m*/ * Retuns the start of day in Date format. * * @param dateToFormat Date to be formatted, cannot be null. * @return Date limited to the end of day e.g. 00.00 of the this day */ public static Date getStartOfDay(Date dateToFormat) { assert dateToFormat != null : "Date to be formatted should not be null"; LocalDate date = dateToFormat.toInstant().atZone(ZoneId.systemDefault()).toLocalDate(); return Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()); } }