Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-3336

Date is not fetched as it is stored - possible Reader problem?

    • Type: Icon: Task Task
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.10.2
    • Component/s: BSON
    • Labels:
      None
    • Environment:

      Hi guys..

      We are using the driver in an ETL project that converts dates. I'm a bit puzzled with this behavior.

      We inserted this record:

      {
      	"_id" : "ZRH",
      	"id" : "ZRH",
      	"name" : "Zürich",
      	"population" : 300000,
      	"factor" : 0.81191,
      	"createDate" : ISODate("1245-04-28T13:27:32.000Z"),
      	"createDateString" : ISODate("1984-05-02T00:00:00.000Z"),
      	"isGood" : false,
      	"countryExtRef" : {
      		"ref" : DBRef("Country", "CHE")
      	},
      	"_loadModifiedData !Screenshot from 2019-06-26 14-34-29.png|thumbnail! " : false,
      	"_loadCreatedAt" : ISODate("2019-06-26T12:16:48.524Z"),
      	"recordOrigin" : "faker"
      },
      

      The problem is with the "createDate" field - as you see it's 1245-04-28T13:27:32.000Z

      Later in the application (well, in our integration tests), i fetch the entity back:

      Document singleRecord = city.find(eq("_id", "ZRH")).first();
      

      I get this:

      So what I see saved in MongoDB is ISODate("1245-04-28T13:27:32.000Z") - I get back "Fri Apr 21 13:27:32 UTC 1245" - somehow 7 days were lost?

      Sadly I lack the ability to really diagnostic this problem - I see that the BSON reader gets the value "-23973085975000" in readInt64() for the specific datetime. This indeed is the rendered Date (April 21).. Which is strange as mongo shell shows me April 28 (which is what I inserted)..

      Any ideas what could be wrong? Thank you so much!

            Assignee:
            Unassigned Unassigned
            Reporter:
            dario.nuevo Dario Nuevo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: