实验一 Java常用工具类编程

public boolean isEquals(MyDate date){ }

public boolean isBefore(MyDate date){ }

public int diffDate(int part,MyDate date){

int diffDays=0; if(part==1){ boolean f=false;

if(this.year

f=true;

boolean f = false;

if (this.year == date.year && this.month == date.month

&& this.day == date.day)

f = true;

return f;

else if(this.year==date.year){ }

else if(this.year==date.year&&this.month==date.month){ }

return f;

if(this.day

f=true;

if(this.month

f=true;

}

if(this.isBefore(date))

diffDays=date.year-this.year;

else if(this.isEquals(date))

diffDays=0;

else

diffDays=this.year-date.year;

else if(part==2){ }

else if(part==3){

if(this.isBefore(date)) if(this.isBefore(date))

diffDays=date.year*12+date.month-this.year*12-this.month;

else if(this.isEquals(date))

diffDays=0;

else

diffDays=this.year*12+this.month-date.year*12-date.month;

diffDays=date.year*12*date.maxMonthDays()+date.month*date.maxMonthDays()

+date.day-this.year*12*this.maxMonthDays()-this.month*this.maxMonthDays()

-this.day;

else if(this.isEquals(date))

diffDays=0;

else

diffDays=this.year*12*this.maxMonthDays()+this.month*this.maxMonthDays()

+this.day-date.year*12*date.maxMonthDays()-date.month*date.maxMonthDays() }

public int calcuWeekDay(MyDate date){

int }

return diffDays;

-date.day;

weekday=((date.year-1900)*365+(date.month)*date.maxMonthDays()+date.day-1)%7; }

public static void main(String[] args){

MyDate date1=new MyDate(2010,3,3); MyDate date2=new MyDate(2012,3,17); System.out.println(date1.toString()); return weekday;

System.out.println(date2.toString()); date1.addDate(1, 2);

System.out.println(date1.toString()); int diffDays=0;

diffDays=date1.diffDate(3, date2);

System.out.println(\年3月3日与2012年3月17日相差\

天\ } }

int weekday1=0,weekday2=0;

weekday1=date1.calcuWeekDay(date1); weekday2=date2.calcuWeekDay(date2);

System.out.println(\年3月3日是星期\System.out.println(\年3月17日是星期\

联系客服:779662525#qq.com(#替换为@)