Wolfgang-Schuetzelhofer / jcypher

Java access to Neo4J graph databases at multiple levels of abstraction
Apache License 2.0
86 stars 15 forks source link

Date rounded to 1s #6

Closed nicoruti closed 8 years ago

nicoruti commented 8 years ago

In MappingUtil, I found the following code:

public static long dateToLong(Date date) {
    long millis = date.getTime();
    if (date instanceof java.sql.Date)
        return millis;
    else if (date instanceof Time)
        return millis;
    else if (date instanceof Timestamp)
        return millis;
    return (millis / 1000) * 1000;
}

What's the reason that a java.util.Date instance is rounded to 1000 millis? When storing java.util.Date objects, they are not stored exactly.

Wolfgang-Schuetzelhofer commented 8 years ago

Hi Nico,

I had some reason to round Date instances (which foolishly I don't remember right now). I will have a look into that matter and either comment the reason in the code or remove the rounding.

best regards, Wolfgang

-----Original Message----- From: Nico Rutishauser notifications@github.com To: Wolfgang-Schuetzelhofer/jcypher jcypher@noreply.github.com Sent: Tue, Oct 20, 2015 2:09 pm Subject: [jcypher] Date rounded to 1s (#6)

In MappingUtil, I found the following code: public static long dateToLong(Date date) { long millis = date.getTime(); if (date instanceof java.sql.Date) return millis; else if (date instanceof Time) return millis; else if (date instanceof Timestamp) return millis; return (millis / 1000) * 1000; }

What's the reason that a java.util.Date instance rounded to 1000 millis? When storing java.util.Dates, they are not stored exactly. — Reply to this email directly or view it on GitHub.

Wolfgang-Schuetzelhofer commented 8 years ago

Hi Nico,

I have removed the rounding of Date instances I had it due to an incorrect usage of Calendar in one of my unit test methods. That should not happen :( The next release, comming this month will contain the corrected mapping code.

best regards and thanks, Wolfgang

Wolfgang-Schuetzelhofer commented 8 years ago

Hi Nico,

I have removed the rounding of Date instances I had it due to an incorrect usage of Calendar in one of my unit test methods. That should not happen :( The next release, comming this month will contain the corrected mapping code.

best regards and thanks, Wolfgang

-----Original Message----- From: Nico Rutishauser notifications@github.com To: Wolfgang-Schuetzelhofer/jcypher jcypher@noreply.github.com Sent: Tue, Oct 20, 2015 2:09 pm Subject: [jcypher] Date rounded to 1s (#6)

In MappingUtil, I found the following code: public static long dateToLong(Date date) { long millis = date.getTime(); if (date instanceof java.sql.Date) return millis; else if (date instanceof Time) return millis; else if (date instanceof Timestamp) return millis; return (millis / 1000) * 1000; }

What's the reason that a java.util.Date instance rounded to 1000 millis? When storing java.util.Dates, they are not stored exactly. — Reply to this email directly or view it on GitHub.

nicoruti commented 8 years ago

Thanks for the quick fix!