@Test public void rewindToBeginningOfDay() { Calendar cal = Calendar.getInstance(); cal.set(2014, 9, 23, 1, 28, 50); Date out = CalendarUtil.rewindToBeginningOfDay(cal.getTime()); cal.setTime(out); assertEquals(23, cal.get(GregorianCalendar.DAY_OF_MONTH)); assertEquals(9, cal.get(GregorianCalendar.MONTH)); assertEquals(2014, cal.get(GregorianCalendar.YEAR)); assertEquals(0, cal.get(GregorianCalendar.MINUTE)); assertEquals(0, cal.get(GregorianCalendar.SECOND)); }
public static Date rewindToBeginningOfDay(Date date) { Calendar cal = buildFromDate(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); }
CalendarUtil { public static Date rewindToBeginningOfDay(Date date) { Calendar cal = buildFromDate(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); } }
CalendarUtil { public static Date rewindToBeginningOfDay(Date date) { Calendar cal = buildFromDate(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); }  }
CalendarUtil { public static Date rewindToBeginningOfDay(Date date) { Calendar cal = buildFromDate(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); }  static String getDayOfWeekThreeChars(Date date, Locale locale); static Date rewindToBeginningOfMonth(Date date); static Date rewindToBeginningOfDay(Date date); static Date getTomorrow(Date from); static Date getYesterday(Date from); static boolean isToday(Date time); static boolean isToday(long date); static boolean isSameDay(Date date1, Date date2); static boolean isSameDayIgnoreYear(Date date1, Date date2); }
CalendarUtil { public static Date rewindToBeginningOfDay(Date date) { Calendar cal = buildFromDate(date); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return cal.getTime(); }  static String getDayOfWeekThreeChars(Date date, Locale locale); static Date rewindToBeginningOfMonth(Date date); static Date rewindToBeginningOfDay(Date date); static Date getTomorrow(Date from); static Date getYesterday(Date from); static boolean isToday(Date time); static boolean isToday(long date); static boolean isSameDay(Date date1, Date date2); static boolean isSameDayIgnoreYear(Date date1, Date date2);  }