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

Date precisision not precise enough (dropps all milliseconds) #833

Closed
falkorichter opened this issue Feb 6, 2015 · 5 comments
Closed

Date precisision not precise enough (dropps all milliseconds) #833

falkorichter opened this issue Feb 6, 2015 · 5 comments
Assignees
Milestone

Comments

@falkorichter
Copy link

falkorichter commented Feb 6, 2015

Java Dates have a millisecond presicsion. Realm queries on dates should respect this precision.

See the example project:
https://github.com/falkorichter/realm-date-fail

The test class in question:
https://github.com/falkorichter/realm-date-fail/blob/master/app/src/androidTest/java/com/sensorberg/android/realmdatecomparison/ApplicationTest.java

The tests shows that with 999 milliseconds difference, realm fails to query correctly.

See the status of this test at: https://travis-ci.org/falkorichter/realm-date-fail.svg?branch=master

@falkorichter falkorichter changed the title Date precisision not precise enough (dropps all milli seconds) Date precisision not precise enough (dropps all milliseconds) Feb 6, 2015
@cmelchior
Copy link
Contributor

Hi @falkorichter
Thank you for the testcase. It is a known issue however, that is also documented in our current limitations: http://realm.io/docs/java/0.78.0/#general

The reason is that we want Realms to function cross-platform eg. NSDate uses floating points internally. This is why we currently only support second-precision (it is the same on iOS), but we definitely want to fix it going forward, it is just not a trivial thing to do.

For now, a workaround would be to store your dates as long and convert them back to Date when needed.

@falkorichter
Copy link
Author

@cmelchior why not drop the Date support completely on Android as it is crippled? Bring it back, when it is working.

@virl
Copy link

virl commented Jul 10, 2015

Please fix this. Really annoying to write all the code to use Dates only to discover that precision is not enough and rewrite everything to use long.

@esco
Copy link

esco commented Sep 20, 2015

👍

1 similar comment
@senorcris
Copy link

👍

This was referenced Sep 30, 2015
@cmelchior cmelchior added P1 and removed P2 labels Dec 16, 2015
@cmelchior cmelchior added this to the 1.0.0-rc1 milestone Feb 10, 2016
@cmelchior cmelchior modified the milestones: 0.90, 1.0.0-rc1 Apr 21, 2016
@kneth kneth added S:Review and removed Blocked This issue is blocked by another issue S:P1 Backlog labels May 2, 2016
@kneth kneth removed the S:Review label May 3, 2016
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants