How to mock Jodatime DateTime with Mockito : <p>I am currently trying to mock a DateTime object so that I can intercept it and make it create a constant (predetermined) DateTime object everytime a new DateTime object is made in my test.</p>

<p>In my actual method, I am creating the DateTime object like this:</p>

<p><code>DateTime start = new LocalDateTime().toDateTime().minusHours(1)</code></p>

<p><code>DateTime end = new LocalDateTime().toDateTime()</code></p>

<p>Right now, I am mocking the LocalDateTime object and DateTime object, but am not sure how to carry on:</p>

<pre><code>@Mock
DateTime dt;

@Mock
LocalDateTime ldt;

@Test
public void test() {
    when(new DateTime()).thenReturn( ???? ); // Stuck here.
    when(new LocalDateTime().toDateTime()).thenReturn(dt);
}
</code></pre>

<p>Any help would be appreciated. Thanks!</p>
