Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add before() and after() to RichDate
There are two implicit conversions for RichDate: implicit def toDate(rd: RichDate): java.util.Date implicit def toCalendar(rd: RichDate)(implicit tz: TimeZone): java.util.Calendar Each has its own implementation of before() and after() methods: Date: boolean before(Date when) Calendar: boolean before(Object when) Their implementation in java.util is pretty much the same (comparing millis), except that Calendar's one does an additional "instanceof Calendar" check. Therefore, an ambiguous behavior arises: - Imagine a user writes: d1.before(d2), where d1, d2: RichDate. - Normally, implicit conversion to Date will happen, and Date.before(Date when) will be applied, comparing the millis. - However, if a user happened to have an implicit TimeZone in the context (as many Scalding job base classes do), the Calendar implicit conversion will happen, Calendar.before(Object when) will be applied, and the `instanceof` check will fail the comparison. before() will always return false! Solution: define before() and after() methods directly in RichDate. This way, implicit conversion will not have to take place.
- Loading branch information