I want to use the difference
method.
It gets a certain date parameter, then calculates the difference between two dates (this and other)
The calculateDate
is the way to get the days passed since the Christian counting. I wanted to use it inside the difference
method, but I get the following error while trying to compile:
cannot find symbol - variable calculateDate
The difference has to be an absolute value, so I added the Math.abs
.
public int difference (Date other) {
return Math.abs(this.calculateDate-other.calculateDate);
}
//computes the day number since the beginning of the Christian counting of years
private int calculateDate (int day, int month, int year)
{
if (month < 3)
{
year--;
month = month + 12;
}
return 365 * year + year/4 - year/100 + year/400 + ((month+1) * 306)/10 + (day - 62);
}