title: Can not retrieve date from JDateChooser in Java
body: <p>I am using <code>JDateChooser</code> from <a href="http://www.toedter.com/en/jcalendar/api/index.html" rel="nofollow noreferrer">here</a></p>
  
  <p>However I can not retrieve the date in format set with the method <code>setDateFormatString</code> while displaying it in console. </p>
  
  <p><img src="https://i.stack.imgur.com/YhM5R.jpg" alt="enter image description here"></p>
  
  <p>In first label shows actual date retrieved from <code>JDateChooser</code> while second label shows the format which I have set. When I select date from <code>JDateChooser</code> I get the date as <code>22-07-2011</code> as shown in image. But when I use <code>getDate</code> method, it will give me date as <code>Fri Jul 22 00:00:00 GMT+05:30 2011</code>. I want only <code>22-07-2011</code>.</p>
  
  <p>Here is my code. I am <strong>using Netbeans IDE 7.0</strong></p>
  
  <pre><code>public JDateChooser() {
      initComponents();
      dateChooser.setDateFormatString("dd-MM-yyyy");
  }
  private void btnDisplayDateActionPerformed(java.awt.event.ActionEvent evt) {
      String dateFromDateChooser = dateChooser.getDate().toString();
      lblDate.setText(dateFromDateChooser);
      lblDateFormat.setText(dateChooser.getDateFormatString().toString());
      System.out.println(dateFromDateChooser);
  }
  public static void main(String args[]) {
      java.awt.EventQueue.invokeLater(new Runnable() {
  
          @Override
          public void run() {
              new JDateChooser().setVisible(true);
          }
      });
  }
  </code></pre>