65 lines
1.1 KiB
Java
65 lines
1.1 KiB
Java
|
public class Date {
|
||
|
|
||
|
private int year;
|
||
|
private int month;
|
||
|
private int day;
|
||
|
|
||
|
public String toString()
|
||
|
{
|
||
|
String Date = String.format("%04d-%02d-%02d", this.year, this.month, this.day);
|
||
|
return Date;
|
||
|
}
|
||
|
public void Lendemain()
|
||
|
{
|
||
|
if(this.month == 1 || this.month == 3 || this.month == 5 || this.month == 7 || this.month == 8 || this.month == 10)
|
||
|
{
|
||
|
if(this.day == 31)
|
||
|
{
|
||
|
this.day = 1;
|
||
|
this.month++;
|
||
|
}
|
||
|
}
|
||
|
if(this.month == 2)
|
||
|
{
|
||
|
if(this.day == 28)
|
||
|
{
|
||
|
this.day = 1;
|
||
|
this.month++;
|
||
|
}
|
||
|
}
|
||
|
if(this.month == 4 || this.month == 6 || this.month == 9 || this.month == 11)
|
||
|
{
|
||
|
if(this.day == 30)
|
||
|
{
|
||
|
this.day = 1;
|
||
|
this.month++;
|
||
|
}
|
||
|
}
|
||
|
if(this.month == 12)
|
||
|
{
|
||
|
if(this.day == 31)
|
||
|
{
|
||
|
this.day = 1;
|
||
|
this.month = 1;
|
||
|
this.year++;
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
this.day++;
|
||
|
}
|
||
|
}
|
||
|
public Date()
|
||
|
{
|
||
|
this.year = 2024;
|
||
|
this.month = 02;
|
||
|
this.day = 6;
|
||
|
}
|
||
|
public static void main(String[] args)
|
||
|
{
|
||
|
Date c = new Date();
|
||
|
System.out.println(c);
|
||
|
c.Lendemain();
|
||
|
System.out.println(c);
|
||
|
}
|
||
|
}
|