title: Format a date and display it using JSTL and EL
body: <p>How do I format and display a <code>Date</code> object in a JSP, most preferably using JSTL and EL but any other solution is welcome? I can not change the bean object. </p>
  
  <p>I have the following class:</p>
  
  <pre><code>import java.util.Date;
  public class Person {
      private Date myDate; 
      public Date getMyDate() {
          return myDate;
      }
      public void setMyDate(Date myDate){
          this.myDate = myDate;
      }
  }
  </code></pre>
  
  <p>I am trying to display the date in this object in a JSP page. When I do this <code>&lt;c:out value="${person.myDate} /&gt;</code> it prints this in the page. <code>2013-06-08 00:00:00.0</code> </p>
  
  <p>What I want to do is remove the time portion of the date and format it to <code>MM-dd-yyyy</code>. </p>
  
  <p>I tried this:</p>
  
  <pre><code>&lt;c:set var="myDate" value="${person.myDate }"/&gt;
  &lt;fmt:formatDate value="${myDate}" type="date" var="formattedDate"/&gt;
  </code></pre>
  
  <p>and it gave me the following error</p>
  
  <blockquote>
    <p>Unable to convert string '${myDate}' to class java.util.Date for attribute value: java.lang.IllegalArgumentException: Property Editor not registered with the PropertyEditorManager</p>
  </blockquote>
  
  <p>Then I tried the following: </p>
  
  <pre><code>&lt;c:set var="myDate" value="${person.myDate }"/&gt;
  &lt;fmt:parseDate value="${myDate }" var="parsedDate" pattern="MM-dd-yyyy"/&gt;
  &lt;c:out value="${parsedDate }"/&gt;
  </code></pre>
  
  <p>and I got:</p>
  
  <blockquote>
    <p>Unparseable date: "${myDate }"</p>
  </blockquote>