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

Unable to Parse Date String in Json String using Document.parse()

    • Type: Icon: New Feature New Feature
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: JSON
    • None
    • Environment:
      Windows 10

      Code:

      static String dateStr = "{ \"name\" : \"Bruce Lee\", \"age\" : 100, \"LossDate\":{\"$date\":'1970-01-01'}}";

      Document doc = Document.parse(dateStr);

       

       

      org.bson.json.JsonParseException: Failed to parse string as a date
      at org.bson.json.JsonReader.visitDateTimeExtendedJson(JsonReader.java:1057)
      at org.bson.json.JsonReader.visitExtendedJSON(JsonReader.java:618)
      at org.bson.json.JsonReader.readBsonType(JsonReader.java:148)
      at org.bson.codecs.DocumentCodec.decode(DocumentCodec.java:149)
      at org.bson.codecs.DocumentCodec.decode(DocumentCodec.java:45)

            Assignee:
            Unassigned Unassigned
            Reporter:
            schen@amica.com shen Chen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: