CalendarUtils { public static Date startOfDay(Calendar calendar, Date date) { calendar.setTime(date); startOfDay(calendar); return calendar.getTime(); }  static void add(Calendar calendar, int field, int amount); static int get(Calendar calendar, int field); static void set(Calendar calendar, int field, int value); static Date getEndOfDST(Calendar calendar); static Date getStartOfDST(Calendar calendar); static boolean isStartOfDay(Calendar calendar); static boolean isEndOfDay(Calendar calendar); static boolean isStartOfMonth(Calendar calendar); static boolean isEndOfMonth(Calendar calendar); static boolean isStartOfWeek(Calendar calendar); static boolean isEndOfWeek(Calendar calendar); static void startOfWeek(Calendar calendar); static void endOfWeek(Calendar calendar); static Date endOfWeek(Calendar calendar, Date date); static Date startOfWeek(Calendar calendar, Date date); static void startOfDecade(Calendar calendar); static Date startOfDecade(Calendar calendar, Date date); static boolean isStartOfDecade(Calendar calendar); static void startOfYear(Calendar calendar); static Date startOfYear(Calendar calendar, Date date); static boolean isStartOfYear(Calendar calendar); static void startOfMonth(Calendar calendar); static void endOfMonth(Calendar calendar); static Date startOfDay(Calendar calendar, Date date); static Date endOfDay(Calendar calendar, Date date); static void startOfDay(Calendar calendar); static void endOfDay(Calendar calendar); static void startOf(Calendar calendar, int field); static boolean isStartOf(Calendar calendar, int field); static boolean areEqual(Date current, Date date); static boolean isSameDay(Calendar today, Date now); static boolean isSame(Calendar today, Date now, int field); static boolean isFlushed(Calendar calendar); @SuppressWarnings("unused")
    static final int ONE_MINUTE; @SuppressWarnings("unused")
    static final int ONE_HOUR; @SuppressWarnings("unused")
    static final int THREE_HOURS; @SuppressWarnings("unused")
    static final int ONE_DAY; static final int DECADE; static final int YEAR_IN_DECADE; }
@Test public void testStartOfDay() { int day = midJune.get(Calendar.DAY_OF_MONTH); CalendarUtils.startOfDay(midJune); assertEquals(day, midJune.get(Calendar.DATE)); midJune.add(Calendar.MILLISECOND, -1); assertEquals(day - 1, midJune.get(Calendar.DATE)); }
@Test public void testFlushedStartOfDay() { CalendarUtils.startOfDay(midJune); assertFlushed(midJune); }