【发布时间】:2016-11-16 00:05:53
【问题描述】:
我正在尝试从 datePicker 检索日期并创建一个 java.util.Date 对象,但我不明白为什么我在 selectedDate 中得到错误的星期几多变的。 currentDate 变量是正确的。
String dateStr = String.valueOf(dayOfMonth) + "/" + String.valueOf(monthOfYear) + "/" + String.valueOf(year);
String timeStr = String.valueOf(hourOfDay) + ":" + String.valueOf(minute);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");
Date selectedDate = simpleDateFormat.parse(dateStr + " " + timeStr);
Date currentDate = Calendar.getInstance().getTime();
System.out.println("selectedDate = " + String.valueOf(selectedDate));
System.out.println("currentDate = " + String.valueOf(currentDate));
输出:
selectedDate = Mon Jun 13 12:44:00 WEST 2016
currentDate = Wed Jul 13 12:44:04 WEST 2016
【问题讨论】: