Converting the org.bson.Document to Java class object
<p>I am using Mongo driver for java 3.2.2 and trying to convert the bson document to valid java object. When I am using the below java code :</p>

<pre><code>Document value = (Document)dataObject.get(VALUE);
Gson gson = new Gson();
CustomClasss classObject = gson.fromJson(value.toJson(),CustomClass.class);
</code></pre>

<p>I am getting the exception while conversion. This exception is due to date and long fields in the value document above. While converting I am getting the extra </p>

<pre><code>$date and $numberlong
</code></pre>

<p>fields from </p>

<pre><code>value.toJson()
</code></pre>

<p>Any suggestions how I can do this conversion.</p>

<p>Thanks in Advance,</p>

<p>Amandeep</p>