电脑故障

位置:IT落伍者 >> 电脑故障 >> 浏览文章

日期打印程序


发布日期:2022/12/28
 

public class MyDate{

private int year;

private int month;

private int day;

public MyDate(int year int month int day){

thisyear = year;

thismonth = month;

thisday = day;

}

public MyDate nextDay(){

int newDay = day + ;

int newMonth = month;

int newYear = year;

if(newDay > ){

newMonth ++;

newDay = ;

}

if(newMonth > ){

newYear ++;

newMonth = ;

}

MyDate newDate =

new MyDate(newYear newMonth newDay)

return newDate;

}

public int getYear(){

return year;

}

public int getMonth(){

return month;

}

public int getDay(){

return day;

}

}

package ch;

public class DateTest{

public static void main(String[] args){

MyDate oldDate = new MyDate(

MyDate newDate = oldDatenextDay()

Systemoutprintln(newDategetYear())

Systemoutprintln(newDategetMonth())

Systemoutprintln(newDategetDay())

}

}

上一篇:将数字转为中文金额的大写方式

下一篇:JNA调用DLL一点小结