public static String CalculateNoofDays(String txtDateValue ) throws Exception
{
String Days="";
String Count="";
String ar[] = new String[2];
ar[0]= Days;
ar[1] =Count;
String MonthOfName = "Unknown";
String days="";
int number_Of_DaysInMonth = 0;
String[] DateValues = txtDateValue.split("/");
//Dateformat df2 = new SimpleDateFormat("HH:mm:ss a MMM dd, yyyy");
//Date cdate = df2.parse(txtDateValue);
String month = DateValues[0];
int mon =Integer.parseInt(month);
//mon = mon-1;
month = String.valueOf(mon);
String day = DateValues[1];
String year = DateValues[2];
int result = Integer.parseInt(year);
int monthcount = mon;
int yearname = result;
switch (monthcount) {
case 1:
MonthOfName = "January";
number_Of_DaysInMonth = 31;
break;
case 2:
MonthOfName = "February";
if ((yearname % 400 == 0) || ((yearname % 4 == 0) && (yearname % 100 != 0))) {
number_Of_DaysInMonth = 29;
} else {
number_Of_DaysInMonth = 28;
}
break;
case 3:
MonthOfName = "March";
number_Of_DaysInMonth = 31;
break;
case 4:
MonthOfName = "April";
number_Of_DaysInMonth = 30;
break;
case 5:
MonthOfName = "May";
number_Of_DaysInMonth = 31;
break;
case 6:
MonthOfName = "June";
number_Of_DaysInMonth = 30;
break;
case 7:
MonthOfName = "July";
number_Of_DaysInMonth = 31;
break;
case 8:
MonthOfName = "August";
number_Of_DaysInMonth = 31;
break;
case 9:
MonthOfName = "September";
number_Of_DaysInMonth = 30;
break;
case 10:
MonthOfName = "October";
number_Of_DaysInMonth = 31;
break;
case 11:
MonthOfName = "November";
number_Of_DaysInMonth = 30;
break;
case 12:
MonthOfName = "December";
number_Of_DaysInMonth = 31;
}
int Totaldays=number_Of_DaysInMonth;
Count=String.valueOf(Totaldays);
int CurrentDays = Integer.parseInt(day);
int tal=Totaldays-CurrentDays;
days= String.valueOf(tal);
days=Days;
return Days;
//return ar;
}
Note: Here What I am trying to do is Based On ExcelDateInput Iam Trying To get Month and Calculate no of days in that month and Subtract the Remaining days here I want No of Days in that Month And Remaining Days
Is this best Approach or any other Easy Way