private void selectFocused() {\r
if (focusedDate != null) {\r
int changedFields = 0;\r
+ /*\r
+ * #5594 set Date (day) to 1 in order to prevent any kind of\r
+ * wrapping of months when later setting the month. (e.g. 31 ->\r
+ * month with 30 days -> wraps to the 1st of the following month,\r
+ * e.g. 31st of May -> 31st of April = 1st of May)\r
+ */\r
+ value.setDate(1);\r
if (value.getYear() != focusedDate.getYear()) {\r
+ value.setYear(focusedDate.getYear());\r
changedFields += VDateField.RESOLUTION_YEAR;\r
}\r
if (value.getMonth() != focusedDate.getMonth()) {\r
+ value.setMonth(focusedDate.getMonth());\r
changedFields += VDateField.RESOLUTION_MONTH;\r
}\r
if (value.getDate() != focusedDate.getDate()) {\r
changedFields += VDateField.RESOLUTION_DAY;\r
}\r
- value.setTime(focusedDate.getTime());\r
+ // We always need to set the date, even if it hasn't changed, since\r
+ // it was forced to 1 above.\r
+ value.setDate(focusedDate.getDate());\r
\r
selectDate(focusedDate.getDate());\r
} else {\r