title: Conversion of java object to Date or DateTime
body: <p>I have a query of inner join tables:</p>
  <p><code>List&lt;Object[]&gt; resultList = entityManager.createNativeQuery(SOME QUERY).getResultList();</code></p>
  <p>When i try to access the elements of <code>Object[]</code> one of which is a <code>Date</code> I tried doing this:</p>
  <pre><code>for(Object[] obj : resultList) {
      Date createdDate = obj[7] !=null ? new Date(Long.valueOf(obj[7] + &quot;&quot;)) : null;
  } 
  </code></pre>
  <p>This gave obvious exception:</p>
  <blockquote>
  <p><code>nested exception is java.lang.NumberFormatException: For input string: &quot;2012-11-20&quot;</code></p>
  </blockquote>
  <p>I changed the <code>Date</code> to <code>DateTime</code> get <code>TO_CHAR(createdDate,'DD.MM.YYYY:HH24:MI:SS')</code></p>
  <p>And tried the below code:</p>
  <pre><code>DateFormat df = new SimpleDateFormat(&quot;yyyy-MM-dd'T'HH:mm:ss.SSSZ&quot;);
  Date createdDate = null;
  try {
      createdDate = df.parse(obj[7] + &quot;&quot;);
  } catch (ParseException e) {
      e.printStackTrace();
  }
  </code></pre>
  <p>This approach results: <code>createdDate = null</code></p>
  <p>Any Suggestions ?</p>