Closed mxdldev closed 4 years ago
hi @mxdldev: the same problem here. Did you find some solution? Thanks in advance
I'm having the same issue any solution?
I found a workaround solution: if you use a dateFormat that has year in it, then SimpleDateFormat won't use 1970 as default year. 1970 was not a leap year.
The problem occurs at this line: https://github.com/florent37/SingleDateAndTimePicker/blob/master/singledateandtimepicker/src/main/java/com/github/florent37/singledateandtimepicker/widget/WheelDayPicker.java#L132
itemText == "Sat 29 Feb"
date = getDateFormat().parse(itemText);
date.toString() == "Sun Mar 01 00:00:00 GMT+01:00 1970"
Thanks for the PR, for some reason the app kept crashing when we set the default date. Instead, I just applied this crappy logic below to fix the problem for now (at least it fixes for next 4years).
if(itemText.equals("Sat 29 Feb")) {
Calendar leapCal = Calendar.getInstance();
leapCal.set(Calendar.YEAR, 2020);
leapCal.set(Calendar.MONTH, 1);
leapCal.set(Calendar.DAY_OF_MONTH, 29);
leapCal.set(Calendar.HOUR_OF_DAY, 0);
leapCal.set(Calendar.MINUTE, 0);
leapCal.set(Calendar.SECOND, 0);
leapCal.set(Calendar.MILLISECOND, 0);
date = leapCal.getTime();
} else {
date = simpleDateFormat.parse(itemText);
}
I'm having the same issue, selecting Feb, 29 makes it return March, 1st.
should be fixed, can you try ?
I chose February 29, 2020 and returned March 1, 2020