title: Mock Date() when you call SimpleDateFormat method
body: <p>Under the following setting</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @SpringApplicationConfiguration(Application.class)
  public class myTest {
  </code></pre>
  
  <p>I have this on my src</p>
  
  <pre><code>DateFormat dataformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  String currentdate = dataformat.format(new Date());
  </code></pre>
  
  <p>And I know Date.getTime() method will be called.</p>
  
  <p>I tried this on my test code. </p>
  
  <pre><code>final Date date = Mockito.mock(Date.class);
  Mockito.when(date.getTime()).thenReturn(dateLongValue);
  </code></pre>
  
  <p>But nothing happened. 
  I also tried with mock up like this</p>
  
  <pre><code>Mockito.when(date.format(new Date())).thenReturn(dateStringValue);
  </code></pre>
  
  <p>But got </p>
  
  <pre><code>java.lang.NullPointerException
  at java.text.DateFormat.format(DateFormat.java:346)
  </code></pre>
  
  <p>This could be easy but I had no luck. Any suggestion would be appreciated.</p>