title: How to mock the default constructor of the Date class with JMockit?
body: <p>I want to mock the default constructor of <code>java.util.date</code> so it does not construct
  a <code>Date</code> object representing the time when it was created, but always the same <code>Date</code> object  (in my example below 31 Dec 2010). I tried doing this with <code>JMockit</code> and <code>JUnit</code>, but when executing my test below, the output is always <code>Thu Jan 01 01:00:00 CET 1970</code>. So what is wrong with my mock of <code>Date()</code>?</p>
  
  <pre><code>import java.util.Date;
  
  import org.junit.*;
  import mockit.*;
  
  public class AppTest {
  
      @Before
      public void setUp() {
          Mockit.setUpMocks(MockedDate.class);
      }
  
      @After
      public void tearDown() {
          Mockit.tearDownMocks();
      }  
  
     @Test
      public void testDate() {
          Date today=new Date();
          System.out.println(today.toString());
      }
  
      @MockClass(realClass=Date.class)
      public static class MockedDate {
  
          @Mock
          public void $init() {
              // Now should be always 31.12.2010!
              new Date(110,11,31);  //110 = 2010! 11 = December! This is sick!
          }
      }
  }
  </code></pre>