title: mongodb realm - how do I work around decode exception on a datetime field?
body: <p>I'm trying to use realm from an android app using java. I'm working my way through the tutorial.  I've setup a simple watch on the collection for a data change. It appears that I need to convert a mongo date to a string (see error message), but the question is how do I do this to avoid the error ?
  Thanks</p>
  <p>This is the field in the mongo doc</p>
  <pre><code>{
    &quot;dateTime&quot;: {
      &quot;$date&quot;: {
        &quot;$numberLong&quot;: &quot;1644483300000&quot;
      }
    },
    
  </code></pre>
  <p>This is part of the RealmObject layout for this (java)</p>
  <pre><code>public class RealmLogEntry extends RealmObject {
  
      @PrimaryKey
      private String _id;
  
      String userId;
  
      String dateTime;
  </code></pre>
  <p>I have setup a watch on the collection, but when I change the collection (via postman) , I get this error when running the android app using Java in android studio. I understand the error, I'm trying to figure out how to move past it.     i.e. convert the dateTime on the mongoDB doc to a string, I've tried changing from a String to a Date type in the Realm Object layout but I can't get that to work either.</p>
  <pre><code>org.bson.codecs.configuration.CodecConfigurationException: An exception occurred when decoding using the AutomaticPojoCodec.
      Decoding into a 'RealmLogEntry' failed with the following exception:
      
      Failed to decode 'RealmLogEntry'. Decoding 'dateTime' errored with: readString can only be called when CurrentBSONType is STRING, not when CurrentBSONType is DATE_TIME.
  </code></pre>