SafeCalendar extends GregorianCalendar { public boolean isEmpty() { return equals(EMPTY) && !isSet(YEAR) && !isSet(MONTH) && !isSet(DAY_OF_MONTH) && !isSet(HOUR_OF_DAY) && !isSet(MINUTE) && !isSet(SECOND); } SafeCalendar();  SafeCalendar(int year);  SafeCalendar(int year, int month);  SafeCalendar(int year, int month, int day);  SafeCalendar(int year, int month, int day, int hour, int minute);  SafeCalendar(int year, int month, int day, int hour, int minute, int second);  SafeCalendar(Locale locale);  SafeCalendar(TimeZone timezone);  SafeCalendar(TimeZone timezone, Locale locale); @Override String toString(); boolean isEmpty(); @Override void set(int field, int value); static final SafeCalendar EMPTY; }
@Test public void testIsEmpty() throws Exception { SafeCalendar notEmtyDate = new SafeCalendar(2016, 5, 15); assertThat(notEmtyDate.isEmpty()).isFalse(); SafeCalendar emptyCalendar = SafeCalendar.EMPTY; assertThat(emptyCalendar.isEmpty()).isTrue(); SafeCalendar startOfEpoch = new SafeCalendar(1970, 0, 0); assertThat(startOfEpoch.isEmpty()).isFalse(); }