title: Checking for a null date before converting to java.sql.date from java.util.date
body: <p>I am using Eclipse Juno, java and MySQL.</p>
  
  <p>I am trying to check if the date is <code>null</code> before converting it to <code>java.sql.Date</code> prior to writing it to the DB.</p>
  
  <p>The following works provided the date is not null:</p>
  
  <pre><code>java.sql.Date sqlPackIn = new java.sql.Date(dateBoxArchived.getValue().getTime());
  </code></pre>
  
  <p>So I am checking for null first:</p>
  
  <pre><code>//TODO check for a null date and handle it for dateBoxArchived and dateBoxPackOut
  java.sql.Date sqlDateArchived = new java.sql.Date(System.currentTimeMillis());
  if (dateBoxArchived.getValue() != null){
      sqlDateArchived = dateBoxArchived.getValue().getTime();
  } else {
    sqlDateArchived = null;
    }
  </code></pre>
  
  <p>However, I am getting an error (<code>Type mismatch can not convert from long to date</code>) on <code>sqlDateArchived = (dateBoxArchived.getValue().getTime());</code></p>
  
  <p>and the recommended fix is to change it to long. I can not find any changed that resolves this.</p>
  
  <p>Your help is greatly appreciated.</p>
  
  <p>Regards,</p>
  
  <p>Glyn</p>