title: Date.getMillisOf NullPointerException
body: <p>I have this method to test</p>
  
  <pre><code>public static AccountingYear newInstance(Date startingDate, Date endingDate) {
      if ((startingDate == null) || (endingDate == null)) {
          throw new AccountingRuntimeException(
                  "the range specify is not correct");
      }
  
      AccountingDaoFactory daoFactory = (AccountingDaoFactory) UnitOfWork
              .getCurrent().getDaoFactory();
      AccountingYear lastAccoutingYear = daoFactory.getAccountingYearDao()
              .getLastAccountingYear();
      Date startDate = lastAccoutingYear.startingDate;
      Date endDate = lastAccoutingYear.endingDate;
      if (lastAccoutingYear != null
              &amp;&amp; isDateRangesOverlap(startDate, endDate, startingDate,
                      endingDate)) {
          throw new AccountingYearCollisionException();
      }
      if (endingDate.before(startingDate)) {
          throw new EndingDateIsBeforeStartingDateException();
      }
      AccountingYear newAccountingYear = new AccountingYear(startingDate,
              endingDate, true);
      if (isOldAccountingYear(startDate, endingDate)) {
          newAccountingYear.setSatus(AccountingYearState.OLD_AND_NOT_CLOSED);
      }
      newAccountingYear.save();
      return newAccountingYear;
  }
  </code></pre>
  
  <p>This is the corresponding test</p>
  
  <pre><code>@Test
  public void newAccountingYearTest() throws Exception {
      AccountingYear accountingYear = Mockito.mock(AccountingYear.class);
      Mockito.when(accountingYear.getAllPeriods()).thenCallRealMethod();
      objectToTest = AccountingYear.newInstance(startingDate, endingDate);
      Assert.assertNotNull(objectToTest);
      Assert.assertEquals(2, objectToTest.getAllPeriods().size());
      Assert.assertEquals(AccountingPeriodType.Opening, objectToTest
              .getAllPeriods().get(0).getType());
      Assert.assertEquals(AccountingPeriodType.Closing, objectToTest
              .getAllPeriods().get(1).getType());
  }
  </code></pre>
  
  <p>When i run the test i have this exception: Java.lang.nullPointerexception, at Java.util.Date.getMillisOf,Date.before().
  This is isOldAccountingYear code that give the exception</p>
  
  <pre><code>public static boolean isOldAccountingYear(Date startDate, Date endingDate2) {
      if (endingDate2.before(startDate)) {
          return true;
      } else {
          return false;
      }
  }
  </code></pre>
  
  <p>Please can you help me solve the problem</p>