Here you can find the source of getStartTimeOfDay(Date date)
Start time of the given date, specific to the second.License
Open Source LicenseParameter
Parameter | Description |
---|---|
date | target date |
public static Date getStartTimeOfDay(Date date)
//package com.java2s; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { /**//from w w w . j a va2 s . c om * <pre> * Start time of the given date, specific to the second. * Example: The date is 2011-12-09 The last time 2011-12-09 00:00:00.000 * </pre> * * <pre> * DateUtils.getStartTimeOfDay(2011-12-09) = 2011-12-09 00:00:00.000 * </pre> * * @param date target date * @return Date */ public static Date getStartTimeOfDay(Date date) { Date result = null; if (date != null) { Calendar calendar = getCalendar(date); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); int day = calendar.get(Calendar.DATE); calendar.set(year, month, day, 0, 0, 0); calendar.set(Calendar.MILLISECOND, 0); result = calendar.getTime(); } return result; } /** * get GregorianCalendar. * * @return Calendar,GregorianCalendar. */ public static Calendar getCalendar() { return new GregorianCalendar(); } /** * get GregorianCalendar with given date. * * @param date Date. * @return Calendar, GregorianCalendar. */ public static Calendar getCalendar(Date date) { Calendar calendar = getCalendar(); calendar.setTime(date); return calendar; } }