AVSystem / scex

Extensible, fast and secure Scala expression evaluation engine
MIT License
21 stars 4 forks source link

Date truncation fix #3

Closed bgrochal closed 5 years ago

bgrochal commented 5 years ago

Changes:

ghik commented 5 years ago

Can you give a quick example of what was wrong with the previous implementation?

bgrochal commented 5 years ago

Sure, previous implementation (DateUtils.truncate(wrapped, Calendar.DAY_OF_YEAR)) throws:

The field 6 is not supported
java.lang.IllegalArgumentException: The field 6 is not supported
    at org.apache.commons.lang3.time.DateUtils.modify(DateUtils.java:1103)
    at org.apache.commons.lang3.time.DateUtils.truncate(DateUtils.java:819)
        ....

The simplest way to reproduce is to change Calendar.DAY_OF_MONTH field back to Calendar.DAY_OF_YEAR and run my tests. Please refer also to the DateUtilImpl#truncateByDay implementation (correct) and this solution.

ghik commented 5 years ago

Oh, so it just never worked :laughing: that's pretty clear.