Im trying to parse some json document which contains date entry as epoch numeric value, after using:
Document.parse(((JSONObject) o).toJSONString())
date format is automatically set to ie. Wed Nov 08 05:10:20 CET 2017
I need different format (need a milliseconds also)
So question is, how to parse ie. "$date" -> "1510114220518"
to some custom formatted string with a Bson Document.parse method ?
JSONArray arrJson = getJsonData(sFilePath);
for (Object o : arrJson) {
Document doc = Document.parse(((JSONObject) o).toJSONString());
Edit: just an update: problem is in Document.parse method because I dont know how to tell .parse function to use custom date format when parsing json document. I always getting some kind of default date format. How to send to .parse method some argument to return me document with all data AND CUSTOM DATE FORMAT ? smtng like :
Format dateFormat = 'yyyy-MM-dd@HH:mm:ss.SSSZ'
Document doc = Document.parse(((JSONObject) o).toJSONString(dateFormat ));```
Im always getting ```Wed Nov 08 05:10:20 CET 2017``` format, **I need a Document with all data and all dates to be in yyyy-MM-dd@HH:mm:ss.SSSZ format** ?
This is sample of json document:
[
{ "_id" : { "user_id" : { "$oid" : "51b76b7459a273c8a6000ed8" }, "updated_at" : { "$date" : 1510114220518 } }, "count" : 153 },
{ "_id" : { "user_id" : { "$oid" : "51b76b7459a273c8a6000ed8" }, "updated_at" : { "$date" : 1511405948977 } }, "count" : 3 },
{ "_id" : { "user_id" : { "$oid" : "51b76b7459a273c8a6000ed8" }, "updated_at" : { "$date" : 1511405948991 } }, "count" : 153 }
and when I do the Document.parse()...date is in some default format like ie. Wed Nov 08 05:10:20 CET 2017