CalendarUtils { public static Calendar fromDateToCalendar(final Date date) { final Calendar cal = new GregorianCalendar(); cal.clear(); cal.setMinimalDaysInFirstWeek(4); cal.setFirstDayOfWeek(Calendar.MONDAY); cal.setTime(date); return cal; } private  CalendarUtils(); static Calendar fromDateToCalendar(final Date date); static int weekDay(final Date date); static int month(final Date date); static int weekOfYear(final Date date); static int day(final Date date); static int dayOfYear(final Date date); static int year(final Date date); static boolean isLeapYear(final Date date); static boolean isAM(final Date date); static boolean isPM(final Date date); static int hour12(final Date date); static int hour24(final Date date); static int minute(final Date date); static int second(final Date date); static int millisecond(final Date date);  }
@Test public void testFromDateToCalendar() throws Exception { final Date date = date(2015, 12, 21, 10, 0, 59, 999); final Calendar calendar = CalendarUtils.fromDateToCalendar(date); assertThat("Expected that the Calendar has the same timestamp than the date", calendar.getTimeInMillis(), is(date.getTime())); }