public LigneReservation(Date dateArrivee, Date dateDepart,
String categorie, int quantite) {
super();
SimpleDateFormat form = new SimpleDateFormat("yyyy-MM-dd");
try {
this.dateArrivee = form.parse(form.format(dateArrivee));
this.dateDepart = form.parse(form.format(dateDepart));
String s = form.format(dateArrivee);
System.out.print(form.parse(s));
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.categorie = categorie;
this.quantite = quantite;
}
This is how I call the method:
ctrlRes.setLigneCourante(ctrlRes.creerLigne(dateArrivee.getDate(),
dateDepart.getDate(), (String)listeCatCh.getSelectedItem(),
Integer.parseInt(champQteCh.getText())));
So I first extract the date from JDateChooser
fields and then I pass them to the constructor LigneReservation
, the String S
is showing me the correct format I want "yyyy-mm-dd" but when I parse it to a date, it gives me dates like this: Wed Mar 13 00:00:00 EDT 2013
. How can I correct it ?
Thanks