Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparing dates #85

Closed
toudidel opened this issue Feb 10, 2014 · 10 comments
Closed

Comparing dates #85

toudidel opened this issue Feb 10, 2014 · 10 comments

Comments

@toudidel
Copy link

Comparing two dates differ always reports change only because one of them has different format.

For instance saving object with date field "2014-02-01 00:00:00.0" receives me message that it has been changed to "Sat Feb 01 00:00:00 CET 2014" (so the same value but other format).

Is it possible to ignore the format comparing dates?

@SQiShER
Copy link
Owner

SQiShER commented Feb 11, 2014

Do you store these dates as strings? Would it be possible to change the type to java.util.Date? That way the differ could simply use the equals method to compare the two dates. Currently I'm working on a new version that might lay the groundwork to provide custom equals methods without the need to modify the classes of the compared objects. But there is still a lot of work to do, before this version is ready to be released.

@toudidel
Copy link
Author

It's strange because I have field of type java.util.Date in fact.
I workarounded it by type checking and in case of date type I compare two strings built from before and after date value.

@SQiShER
Copy link
Owner

SQiShER commented Feb 11, 2014

Interesting, I would have sworn that Date works fine, but now that you say it I'm not sure anymore. I'll make sure to double-check before the next release. Good to hear that you found a workaround!

@SQiShER SQiShER added the Bug label Feb 11, 2014
@SQiShER SQiShER added this to the 0.90 milestone Feb 11, 2014
@yrodiere
Copy link

For the record, the implementation of Date.equals() only returns true when given an actual java.util.Date) as a parameter : it actually performs a test akin to other.getClass().equals(java.util.Date.class) instead of other instanceof Date.
This is an issue when working with ORMs, such as Hibernate for instance, which uses java.sql.Date and other subclasses of java.util.Date when retrieving entities from a database. In our team, we worked around this by comparing the timestamp (Date#getTime()) instead of the date itselft; maybe that's what you need, too?

@toudidel
Copy link
Author

Yes, comparing timestamp may be also a good workaround.

@SQiShER SQiShER modified the milestones: 0.90, Backlog (Smart collection diffing) Aug 25, 2014
@SQiShER SQiShER closed this as completed in f00dc3e Mar 8, 2015
@yrodiere
Copy link

Hi,

It seems you fixed it, thanks! Any idea when this could be included in a release?

@SQiShER
Copy link
Owner

SQiShER commented Apr 28, 2015

I can put a new release on my to-do list for this week. 😃

@yrodiere
Copy link

That would be greatly appreciated :)

@SQiShER SQiShER modified the milestones: 0.92, Backlog May 2, 2015
@SQiShER
Copy link
Owner

SQiShER commented May 2, 2015

@fenrhil Release 0.92 is out! Enjoy :)

@yrodiere
Copy link

yrodiere commented May 4, 2015

Great :) Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants