public static Calendar getCalendar(Object date, Calendar defaultValue) {
        Calendar cal = new GregorianCalendar();
        if (date instanceof java.util.Date) {
            cal.setTime((java.util.Date) date);
            return cal;
        } else if (date != null) {
            Optional<Date> d = tryToParseDate(date);
            if (!d.isPresent()) {
                return defaultValue;
            }
            cal.setTime(d.get());
        } else {
            cal = defaultValue;
        }
        return cal;
    }
@Test
    public void testGetCalendarObjectCalendarWithValidStringAndNullDefault() {
        Calendar cal = new GregorianCalendar();
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        Date time = cal.getTime();
        for (int formatId : new int[]{DateFormat.SHORT, DateFormat.MEDIUM,
                DateFormat.LONG, DateFormat.FULL}) {
            DateFormat formatter = DateFormat.getDateInstance(formatId);
            assertEquals(cal,
                    Converter.getCalendar(formatter.format(time), null));
        }
    }