eXparity / hamcrest-date

A Java library which provides a suite hamcrest matchers for matching dates, times, and moments in time
BSD 3-Clause "New" or "Revised" License
70 stars 11 forks source link

UnsupportedOperationException with java.sql.Date #27

Closed barracuda317 closed 4 years ago

barracuda317 commented 5 years ago

In DateWrapper you are using toInstant, but toInstant throws an UnsupportedOperationException if Date is a instance of java.sql.Date.

I was using an old version of hamcrest-date (1.1.0) and that was not a problem.

Is there a way to circumvent the toInstant-call for java.sql.Date?

stewbis commented 5 years ago

Hi, that's just a bug with the latest version. If you'd like to raise a PR to fix then please do - if not I can fix the bug. The newer versions only added support for Java 8 data types; if you don't need support for these dates you can stay on version 1.10.

stewbis commented 5 years ago

Hi, don;t worry about a PR - I'll code a fix up and cut a new release. The option to go back to version 1.1.0 is still open though if you don't need support for Java 8 dates

stewbis commented 4 years ago

java.sql.Date is now supported via the DateMatchers and also have their own specialized matchers in SqlDateMatchers e.g.

assertThat(new java.sql.Date(), SqlDateMatchers.isMonday())