Take a look at the implementation getTime()that is in the superclass GregorianCalendarwith the name Calendar:
public final Date getTime() {
return new Date(getTimeInMillis());
}
This means that you should probably try to make fun of getTimeInMillis():
Mockito.when(gregorianCalendar.getTimeInMillis()).thenReturn(date.getTime());
Alexr source
share