public String getDate(int n)
{
String output = "";
String[] arr1 = new String[]{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
String[] arr2 = new String[]{"31","28","31","30","31","30","31","31","30","31","30","31" };
int year = 1900;
System.out.println(year);
while(n>366)
{
if(isLeapYear(year))
{
n-=366;
year++;
}
else
{
n-=365;
year++;
}
System.out.println(year);
}
if(!isLeapYear(year) && n>365)
{
System.out.println(year);
n-=365;
year++;
}
int i=0;
int tempN=Integer.parseInt(arr2[i+1]);
if(isLeapYear(year) && tempN==28)
tempN=29;
while(n>tempN)
{
int num = Integer.parseInt(arr2[i]);
if(i==1 && isLeapYear(year))
num++;
n-=num;
i++;
if(i!=11)
{
tempN = Integer.parseInt(arr2[i+1]);
if(isLeapYear(year) && tempN==28)
tempN=29;
}
}
output = arr1[i]+" "+year;
return output;
}
public boolean isLeapYear(int theYear)
{
// Is theYear Divisible by 4?
if (theYear % 4 == 0)
{
// Is theYear Divisible by 4 but not 100?
if (theYear % 100 != 0)
return true;
// Is theYear Divisible by 4 and 100 and 400?
else if (theYear % 400 == 0)
return true;
// It is Divisible by 4 and 100 but not 400!
else
return false;
}
return false;
}