String selectedDate = "2012-" + createdMonth
+ "-" + createdDay;
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-mm-dd");
try {
Date createdDate = dateFormat.parse(selectedDate);
} catch (ParseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
int x = JOptionPane.showOptionDialog(frame,
"Here is your new booking schedule:\n "
+ "Timeslot: "
+ selectedTimeslot + "\n"
+ "Date: " + createdDate + "\n"
+ "Continue?",
"Booking Confirmation",
JOptionPane.YES_NO_OPTION,
JOptionPane.QUESTION_MESSAGE, null,
options, options[1]);
问题是 JOptionPane 中的 createdDate 无法解析为变量。这是为什么?我已经尝试了一切,比如在 try catch 之外初始化 Date 对象,但它仍然不起作用。帮助!