title: Primefaces Calendar component & date conversions
body: <p>I am using primefaces' calendar component. I have a corresponding string in VO. While saving in database, I need to convert the string to java.sql.date. </p>
  
  <p><strong>xhtml</strong>:</p>
  
  <pre><code>&lt;p:calendar value="#{articlePromo.startDate}"
      id="vendorStartDateInputTxt" pattern="dd/MM/yyyy" mode="popup" showOn="button"&gt;
      &lt;f:convertDateTime type="date"  dateStyle="short" pattern="dd/MM/yyyy" /&gt;
  &lt;/p:calendar&gt;
  </code></pre>
  
  <p>The startDate (String) has the value : Sat Apr 21 05:30:00 IST 2012</p>
  
  <p><strong>Java method to get sql Date</strong></p>
  
  <pre><code>public static Date getSQLDate(String strDate) {
      java.sql.Date sqlDate = null;
      try {
          SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");
          java.util.Date dt = formatter.parse(strDate);
          sqlDate = new java.sql.Date(dt.getTime());
      } catch (Exception e) {
          e.printStackTrace();
      }
  
      return sqlDate;
  }
  </code></pre>
  
  <p>While converting java.util.date of calendar, I used the pattern dd/MM/yyyy. But the date it got converted to is: Sat Apr 21 05:30:00 IST 2012.</p>
  
  <ol>
  <li>Is anything incorrect with <strong>f:convertDateTime</strong> tag written above.</li>
  <li>If not, how can I convert this string to sql date. Not able to understand what format should be given.</li>
  </ol>
  
  <p>Thanks,
  Shikha</p>