Hi,
I’m trying to use realm from an android app. I’m working my way through the tutorial. I’ve setup a simple watch. It appears that I need to convert a mongo date to a string , but the question is how do I do this ?
Thanks
This is the field in the mongo doc
{
"dateTime": {
"$date": {
"$numberLong": "1644483300000"
}
},
This is part of the RealmObject layout for this (java)
public class RealmLogEntry extends RealmObject {
//public class RealmLogEntry implements RealmModel {
@PrimaryKey
private String _id;
String userId;
String dateTime;
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.
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.