[JAVA-2439] MongoCursor returns the date variable as integer value Created: 31/Jan/17  Updated: 27/Oct/23  Resolved: 28/Feb/17

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Blocker - P1
Reporter: Vinoth Kumar Assignee: Ross Lawley
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Capture.PNG    
Issue Links:
Duplicate
is duplicated by JAVA-2447 Implement Extended JSON specification Closed

 Description   

While Querying using MongoCursor the date field returned as integer variable. But when i use dbobject it seems to be return as perfect.

MongoDB:

When I query using the MongoCursor

{"date" : { "$date" : 1468476847025 }}

When I query using the DBCursor

{"date" : { "$date" : "2016-07-23T15:02:12.728Z" }}

The method getDB(String) from the type Mongo is deprecated



 Comments   
Comment by Ross Lawley [ 28/Feb/17 ]

We don't have a tentative release date yet, however the next release is scheduled for this quarter.

I'm marking this ticket as works as designed only because the current format for the date mirrored the Json emitted by earlier versions of MongoDB tools. As mentioned in a similar ticket (JAVA-2454) there is some inconsistency between different MongoDB versions, tools and the outputted extended Json. All tools should be able to consume the older Json data formats but they may generate newer formats.

Its because of this the drivers team has been working on examining and specifying the extended Json format. Please see JAVA-2447, for the specification information and that ticket will cover this work. As mentioned previously JAVA-1772 is the initial steps for easier customisation and is already in master.

All the best,

Ross

Comment by Vinoth Kumar [ 13/Feb/17 ]

HI Ross
Thanks for the clarification.
Let me know is there any tentative release date for 3.5.0.

Thanks
Vinoth

Comment by Ross Lawley [ 31/Jan/17 ]

Hi vinothkumarsubbu,

Thanks for the ticket. You are correct that the Document#toJson method defaults to returning dates in the following format:

{"date" : { "$date" : <date as milliseconds> }}

This supports all dates including pre-epoch dates. In the next release (3.5.0) we are making it easier to customise how bson types are represented in Json - see JAVA-1772. This code is already available for testing as a snapshot from sonatype. It should be noted that snapshots are only recommended for testing purposes.

I hope that clarifies the situation.

Ross

Generated at Thu Feb 08 08:57:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.