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;
}
这就是我调用该方法的方式:
ctrlRes.setLigneCourante(ctrlRes.creerLigne(dateArrivee.getDate(),
dateDepart.getDate(), (String)listeCatCh.getSelectedItem(),
Integer.parseInt(champQteCh.getText())));
所以我首先从字段中提取日期JDateChooser
,然后将它们传递给构造函数LigneReservation
,字符串S
向我显示了我想要的正确格式“yyyy-mm-dd”但是当我将它解析为日期时,它给了我这样的日期:Wed Mar 13 00:00:00 EDT 2013
. 我该如何纠正它?
谢谢