e.printStackTrace(); } }
public static void main(String[] args) {
CTime time = new CTime(\ time.printNextTime(); } }
2、自定义编写函数 package NextDate; //NextDate函数部分代码 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class NextDate {
private int year;
private int month;
private int day;
public NextDate(int year, int month, int day) { this.year = year;
this.month = month; this.day = day; }
public NextDate() { year = 1; month = 1; day = 1; }
public int getyear() { return this.year; }
public int getmonth() { return this.month; }
public int getday() { return this.day; }
public boolean isleap() { boolean fla1 = true;
if ((this.year % 4 == 0 && this.year % 100 != 0) || (this.year % 400 == 0)) { fla1 = true; } else { fla1 = false; } return fla1;
}
public void nextday() { switch (this.month) { case 1: case 3: case 5: case 7: case 8: case 10:
if (this.day == 31) { this.month = this.month + 1; this.day = 1; } else {
this.day = this.day + 1; } break; case 4: case 6: case 9: case 11:
if (this.day == 30) { this.month = this.month + 1; this.day = 1; } else {
this.day = this.day + 1; } break; case 12:
if (this.day == 31) {
this.month = 1; this.day = 1;
this.year = this.year + 1; } else {
this.day = this.day + 1; } break; case 2:
if (this.isleap()) { if (this.day == 29) { this.day = 1; this.month = 3; } else {
this.day = this.day + 1; } }else {
if (this.day == 28) { this.day = 1; this.month = 3; } else {
this.day = this.day + 1; } } break; } }
public boolean nextday(NextDate date) { boolean fla = true;
if ((date.year < 1912) || (date.year > 2050)) { fla = false; } else {
if ((date.month < 1) || (date.month > 12)) { fla = false; } else {
switch (date.month) { case 1: case 3: case 5: case 7: case 8: case 10:
if (date.day == 31) { date.month = date.month + 1; date.day = 1; } else {
if(date.day<31&&date.day>=1){ date.day = date.day + 1; } else{ fla=false; } } break; case 4: