Merge "Fix incorrect leap year logic"

This commit is contained in:
Neil Fuller
2019-04-17 14:50:04 +00:00
committed by Gerrit Code Review

View File

@@ -581,7 +581,7 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate {
return DatePicker.class.getName(); return DatePicker.class.getName();
} }
public static int getDaysInMonth(int month, int year) { private static int getDaysInMonth(int month, int year) {
switch (month) { switch (month) {
case Calendar.JANUARY: case Calendar.JANUARY:
case Calendar.MARCH: case Calendar.MARCH:
@@ -597,7 +597,7 @@ class DatePickerCalendarDelegate extends DatePicker.AbstractDatePickerDelegate {
case Calendar.NOVEMBER: case Calendar.NOVEMBER:
return 30; return 30;
case Calendar.FEBRUARY: case Calendar.FEBRUARY:
return (year % 4 == 0) ? 29 : 28; return ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) ? 29 : 28;
default: default:
throw new IllegalArgumentException("Invalid Month"); throw new IllegalArgumentException("Invalid Month");
} }