title: DATE FORMAT SQL
body: <p>I have a table called Abbonamento that has the following attributes:</p>
  
  <pre><code>Abbonamento(idAbbonamento, tipo, DataInizio, DataScadenza, ....)
  </code></pre>
  
  <p>DataInizio and DataScadenza are of type <code>DATE</code>.
  The problem borns when I do a select on this table:</p>
  
  <pre><code>        String queryAbb = "select idabbonamento, tipo, DATE_FORMAT(datainizio,'%d-%m-%Y'), DATE_FORMAT(datascadenza,'%d-%m-%Y'), ...;
                         prest = con.prepareStatement(queryAbb);
          rs = prest.executeQuery();
          while (rs.next()) {
              a=new Abbonamento();
              a.setIdAbbonamento(rs.getInt(1));
              a.setTipo(rs.getString(2));
              a.setDataInizio(rs.getDate(3));
              System.out.println(rs.getDate(3)); 
              a.setDataScadenza(rs.getDate(4));
              ...
          }
  </code></pre>
  
  <p>Now, if the date DataInizio in the db is for example <code>2013-11-05 00:00:00</code> I would like to have <code>05-11-2013</code> but the println prints <code>0004-10-13</code>.</p>
  
  <p>What's wrong with the code above?</p>