我得到了日期格式的代码。我的examDateFormat打印出来像这样:
Jan 01 = 1
Feb 02 = 11
March 03 = 21
April 04 = 31
例如在2月,它应该显示02但它显示11.我不知道如何修复该逻辑。请帮帮我看看。谢谢!
for (ExamTimetable exam: listOfExam) {
Calendar cal = Calendar.getInstance();
DateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
Date date = null;
date = format.parse(exam.getM_scheduledDate());
cal.setTime(date); //correct date
String examDateFormat = cal.get(Calendar.DAY_OF_MONTH) + "/" + cal.get(Calendar.MONTH) + 1 + "/" + cal.get(Calendar.YEAR);
int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
String day = new DateFormatSymbols().getShortWeekdays()[dayOfWeek];
if (examDateFormat.equals(mDates)) {
dataList.add(new ExamInfo(exam.getM_subjectFullName(), exam.getM_subjectCode(), examDateFormat + " " + "(" + day + ")", exam.getM_startTime(), exam.getM_endTime(), exam.getM_venueId(), exam.getM_seatingNo()));
}
}