How to convert this string to Date? || How to read/write date in mongodb?
Lets say I have a class User. A user got a name, gender, ..., born. When I got an userobject I can insert that in the database. Thats fine. There is just a problem with date. Im trying this:

    String json = "{'name': '" + user.getName() + "', 'born': '" + user.getBorn() + "'}";
    DBObject o = (DBObject)JSON.parse(json);
    myCollection.insert(o); 
`user.getBorn()` is returning a Date, but in the database it is a string. So if Im reading it I get something like `Fri Sep 05 00:00:00 GMT+01:00 1980` as a string and thats not good :) I would like have a Date. So there is maybe more the one option(?) Maybe I could convert this DateString somehow to Date? Or maybe I could insert the document without a string? Thank you for any help!
How to convert this string to Date? || How to read/write date in mongodb?
===

Lets say I have a class User. A user got a name, gender, ..., born. When I got an userobject I can insert that in the database. Thats fine. There is just a problem with date. Im trying this:

    String json = "{'name': '" + user.getName() + "', 'born': '" + user.getBorn() + "'}";
    DBObject o = (DBObject)JSON.parse(json);
    myCollection.insert(o); 
`user.getBorn()` is returning a Date, but in the database it is a string. So if Im reading it I get something like `Fri Sep 05 00:00:00 GMT+01:00 1980` as a string and thats not good :) I would like have a Date. So there is maybe more the one option(?) Maybe I could convert this DateString somehow to Date? Or maybe I could insert the document without a string? Thank you for any help!