Details
-
Bug
-
Status: Closed
-
Blocker
-
Resolution: Fixed
-
3.3
-
None
Description
Commons lang3 screwed up my system after upgraded to 3.3 last night!
We use DateUtils.getFragmentInDays(Date, Calendar.MONTH) to extract days for later use. Basically (in 3.2), 'today' (Mar. 13) returns 13, but, it returns 12 in 3.3!
I compared the underlying method org.apache.commons.lang3.time.DateUtils.getFragment(Calendar, int, int) between 3.2 and 3.3:
3.2
// Fragments bigger than a day require a breakdown to days switch (fragment) { case Calendar.YEAR: result += (calendar.get(Calendar.DAY_OF_YEAR) * MILLIS_PER_DAY) / millisPerUnit; break; case Calendar.MONTH: result += (calendar.get(Calendar.DAY_OF_MONTH) * MILLIS_PER_DAY) / millisPerUnit; break; }
3.3
// Fragments bigger than a day require a breakdown to days switch (fragment) { case Calendar.YEAR: result += ((calendar.get(Calendar.DAY_OF_YEAR) -1) * MILLIS_PER_DAY) / millisPerUnit; break; case Calendar.MONTH: result += ((calendar.get(Calendar.DAY_OF_MONTH) -1) * MILLIS_PER_DAY) / millisPerUnit; break; default: break; }
Is there ANY ANY reason for adding '-1' in 3.3?! Plus, do you have any unit test for this method?
Attachments
Attachments
Issue Links
- relates to
-
LANG-951 Fragments are wrong by 1 day when using fragment YEAR or MONTH
- Closed