How to check selected year and month leap year or not
please used this code
public boolean isValidMonthOfDays( String month) {
int bDay = Integer.parseInt(Prefs.getString(AUtils.PREFS.SUR_BIRTH_DAY,""));
int bMonth = Integer.parseInt(Prefs.getString(AUtils.PREFS.SUR_BIRTH_MONTH,""));
int bYear = Integer.parseInt(Prefs.getString(AUtils.PREFS.SUR_BIRTH_YEAR,""));
String monthValue ;
int number_Of_DaysInMonth = 0;
switch (month) {
case "01":
monthValue = "01";
number_Of_DaysInMonth = 31;
if (number_Of_DaysInMonth >= bDay && month.equals(monthValue)){
AUtils.info(context, "Valid date of January");
}else {
AUtils.warning(context, "Invalid date of January");
return false;
}
break;
case "02":
monthValue = "02";
if (((bYear % 4 == 0) && (bYear % 100 != 0)) || (bYear % 400 == 0)) {
number_Of_DaysInMonth = 29;
} else {
number_Of_DaysInMonth = 28;
}
if (number_Of_DaysInMonth >= bDay && month.equals(monthValue)){
AUtils.info(context, "Valid date of February");
}else {
AUtils.warning(context, "Invalid date of February");
return false;
}
break;
case "03":
monthValue = "03";
number_Of_DaysInMonth = 31;
if (number_Of_DaysInMonth >= bDay && month.equals(monthValue)){
AUtils.info(context, "Valid date of March");
}else {
AUtils.warning(context, "Invalid date of March");
return false;
}
break;
case "04":
monthValue = "04";
number_Of_DaysInMonth = 30;
if (number_Of_DaysInMonth >= bDay && month.equals(monthValue)){
AUtils.info(context, "Valid date of April");
}else {
AUtils.warning(context, "Invalid date of April");
return false;
}
break;
case "05":
monthValue = "05";
number_Of_DaysInMonth = 31;
if (number_Of_DaysInMonth >= bDay && month.equals(monthValue)){
AUtils.info(context, "Valid date of May");
}else {
AUtils.warning(context, "Invalid date of May");
return false;
}
break;
case "06":
monthValue = "06";
number_Of_DaysInMonth = 30;
if (number_Of_DaysInMonth >= bDay && month.equals(monthValue)){
AUtils.info(context, "Valid date of June");
}else {
AUtils.warning(context, "Invalid date of June");
return false;
}
break;
case "07":
monthValue = "07";
number_Of_DaysInMonth = 31;
if (number_Of_DaysInMonth >= bDay && month.equals(monthValue)){
AUtils.info(context, "Valid date of July");
}else {
AUtils.warning(context, "Invalid date of July");
return false;
}
break;
case "08":
monthValue = "08";
number_Of_DaysInMonth = 31;
if (number_Of_DaysInMonth >= bDay && month.equals(monthValue)){
AUtils.info(context, "Valid date of August");
}else {
AUtils.warning(context, "Invalid date of August");
return false;
}
break;
case "09":
monthValue = "09";
number_Of_DaysInMonth = 30;
if (number_Of_DaysInMonth >= bDay && month.equals(monthValue)){
AUtils.info(context, "Valid date of September");
}else {
AUtils.warning(context, "Invalid date of September");
return false;
}
break;
case "10":
monthValue = "10";
number_Of_DaysInMonth = 31;
if (number_Of_DaysInMonth >= bDay && month.equals(monthValue)){
AUtils.info(context, "Valid date of October");
}else {
AUtils.warning(context, "Invalid date of October");
return false;
}
break;
case "11":
monthValue = "11";
number_Of_DaysInMonth = 30;
if (number_Of_DaysInMonth >= bDay && month.equals(monthValue)){
AUtils.info(context, "Valid date of November");
}else {
AUtils.warning(context, "Invalid date of November");
return false;
}
break;
case "12":
monthValue = "12";
number_Of_DaysInMonth = 31;
if (number_Of_DaysInMonth >= bDay && month.equals(monthValue)){
AUtils.info(context, "Valid date of December");
}else {
AUtils.warning(context, "Invalid date of December");
return false;
}
break;
}
return true;
}