I have written a function but it does not give an actual O/P...
public int date(Object O) {
if (O instanceof Date) {
Date d1 = (Date) O;
The problem in the program is :
In the program, variable mm(month) is coming as 4 and O/P is coming for 4th month only.
(The first month of the year is 0)
To Solve this, you need to increase the month value.
dd = cal.get(Calendar.DAY_OF_MONTH);
mm = cal.get(Calendar.MONTH);
yy = cal.get(Calendar.YEAR);
//Solution for the issue
mm++;
if (dd == 29 && mm == 02 && yy == 1900)
return 60;
long nSerialDate = ((1461 * (yy + 4800 + ((mm - 14) / 12))) / 4)
+ ((367 * (mm - 2 - 12 * ((mm - 14) / 12))) / 12)
- ((3 * (((yy + 4900 + ((mm - 14) / 12)) / 100))) / 4) + dd
- 2415019 - 32075;