*/
@SuppressWarnings("unused")
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int year, month, day;
MyDate next = new MyDate();
MyDate previous = new MyDate();
try {
year = in.nextInt();
month = in.nextInt();
day = in.nextInt();
} catch (Exception e) {
System.out.println("请输入正确的数字");
return;
}
if (!isCorrect(year, month, day)) {
System.out.println("请输入正确的日期");
return;
}
if (!isFirst(year, month, day) && !isLast(year, month, day)) {
next.setMonth(month);
next.setYear(year);
next.setDay(day + 1);
previous.setYear(year);
previous.setMonth(month);
previous.setDay(day - 1);
} else if (isFirst(year, month, day)) {
if (!isFirstYear(year, month, day)) {
previous.setYear(year);
previous.setMonth(month - 1);
if (isLeapYear(year)) {
previous.setDay(days29[month - 2]);
} else {
previous.setDay(days28[month - 2]);
}
} else {
previous.setYear(year - 1);
previous.setMonth(12);
previous.setDay(31);
}
next.setMonth(month);
next.setYear(year);
next.setDay(day + 1);
} else if (isLast(year, month, day)) {
if (!isLastYear(year, month, day)) {
next.setMonth(month + 1);
next.setYear(year);
next.setDay(1);
} else {
next.setMonth(1);
next.setYear(year + 1);
next.setDay(1);
}
previous.setYear(year - 1);
previous.setMonth(month);
previous.setDay(day - 1);
}
System.out.println("下一天是" + next);
System.out.println("前一天是" + previous);
return;
}