Envin
Envin

Reputation: 1523

Adding Joda DateTime to MongoDB -- Can't Serialize

I am taking a DateTime object and trying to persist it into MongoDB. Is there a way to implement "Serializable" for Joda Time?

Here is the error I am receiving

java.lang.RuntimeException: java.lang.IllegalArgumentException: can't serialize class org.joda.time.DateTime

I would prefer to keep the format as DateTime, is the more appropriate solution to convert it to a Java Date? I can do that if need be but I'd rather not just to keep the date format consistent.

Thanks!

Upvotes: 2

Views: 2534

Answers (1)

Aravind Yarram
Aravind Yarram

Reputation: 80194

Currently only primitive types, Date and classes that extend DBObject are supported through the java driver. You are better of using a mapper framework like Spring MongoDB if you want to keep your POJO's as is.

Upvotes: 2

Related Questions