import java.util.Calendar;
import java.util.GregorianCalendar;
public class DateV2 {
private int yymmdd;
public DateV2(int y, int m, int d) {
this.yymmdd = y * 10000 + m * 100 + d;
}
public DateV2() {
GregorianCalendar cal = new GregorianCalendar();
this.yymmdd = cal.get(Calendar.YEAR) * 10000 + (cal.get(Calendar.MONTH) + 1) * 100 + cal.get(Calendar.DAY_OF_MONTH);
}
public int getDay() {
return this.yymmdd % 100;
}
public void setDay(int d) {
this.yymmdd = this.getYear() * 10000 + this.getMonth() * 100 + d;
}
public int getMonth() {
return (this.yymmdd % 10000) / 100;
}
public void setMonth(int m) {
this.yymmdd = this.getYear() * 10000 + m * 100 + this.getDay();
}
public int getYear() {
return this.yymmdd / 10000;
}
public void setYear(int y) {
this.yymmdd = y * 10000 + this.getMonth() * 100 + this.getDay();
}
public boolean before(DateV2 uneDate) {
return this.yymmdd < uneDate.yymmdd;
}
public boolean after(DateV2 uneDate) {
return this.yymmdd > uneDate.yymmdd;
}
public String toString() {
return (this.getDay() + "/" + this.getMonth() + "/" + this.getYear());
}
public static void main(String[] args) {
DateV2 dateDuJour = new DateV2();
System.out.println(dateDuJour.toString());
System.out.println("On est quel quel jour ? " + dateDuJour.getDay());
DateV2 fetNatAnDernier = new DateV2(2024,07,14);
System.out.println(fetNatAnDernier.toString());
System.out.println(fetNatAnDernier.before(dateDuJour));
}
}