[JAVA-565] JSONParser issue for ISODate Created: 08/May/12 Updated: 25/Jun/13 Resolved: 27/Aug/12 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | API |
| Affects Version/s: | 2.7.3 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | M Schaffer | Assignee: | Bryan Reinero |
| Resolution: | Done | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 7 |
||
| Description |
|
I am using the JSON.parse method to parse a string query. It works fine until I have an ISODate in the query. db.runCommand({aggregate:"test", pipeline:[{$match:{date:ISODate("2012-05-01T12:30")}}]}); Code: Error: |
| Comments |
| Comment by Bernd Zuther [ 31/Aug/12 ] |
|
I had the same problem and i could not understand the anwser of Bryan. Then i experience a little bit, with the JSON class. DBObject object = new BasicDBObject(); serialize is: { "date" : { "$date" : "2012-08-31T17:30:01.882Z"}} so this command should work. }}]}); PLEASE BE CAREFUL must be replaced { "date" : { "$date" : "2012-08-31T17:30:01.882Z"}}} When using the mongodb hadoop adapter it is also imported to convert dates in this way: mongo.input.query={orderDate : {$gte : {$date : "2012-08-30T00:00:00.000Z"}, $lt: {$date : "2012-08-30T00:00:00.000Z"}}} |
| Comment by Bryan Reinero [ 12/Jun/12 ] |
|
The parser accepts these two date formats: seconds -> "yyyy-MM-dd'T'HH:mm:ss'Z'" or Just add seconds to your $date value and the aggregation command should work. Here's the JSON doc that I had success with: { "aggregate" : "test", pipeline : [ {$match : { date : { $date : "2012-05-01T12:30:00Z" }} } ] } |