我的代码可以完美地编译和运行,但是当我的任何日期是星期六时,输出为“null”而不是“SATURDAY”。下面将举例说明这个问题。
我试图在我的“getDayOfWeek”方法上更改我的 if 语句,但我似乎没有解决方案,我也试图从有经验的编码人员那里获得帮助,但由于 java 不是他们的主要语言,他们似乎在苦苦挣扎......
预期成绩:
java MyCalendar 29/02/2019
29/02/2019 in not a valid date, please re-input a valid date: 25/05/2019
25/05/2019 is a Saturday and located in the fourth week of May 2019
The calendar of May 2019 is:
SUN MON TUE WED THU FRI SAT
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
实际结果:
25/05/2019 is a null located in the FOURTH week of MAY 2019
The calendar of May 2019 is:
SUN MON TUE WED THU FRI SAT
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
另一个日期(不是星期六)的结果:
24/05/2019 is a FRIDAY located in the FOURTH week of MAY 2019
The calendar of May 2019 is:
SUN MON TUE WED THU FRI SAT
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
特定问题:输出在星期六当天的所有日期打印 null,而其他非星期六的日期将实现所需的正确输出。
HUX布斯
狐的传说
相关分类