DateTime Java not serializing properly

Hey all,

Today I have come across an issue with java DateTime class not being serialized the way id want to.
I have a field called updatedAt which is of type org.joda.time.DateTime and when I save the document to DB it stores it as follows:

publishedAt": 1599745623079,

and not the way Id like to (DATE_FORMAT_STRING = “yyyy-MM-dd’T’HH:mm:ss.SSS’Z’”)
I also have this annotation in my model

@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = DATE_FORMAT_STRING)

Any idea how to fix this so that my field is being serialized properly?

Hi Sebastian,

Are you using Spring Data Couchbase? If so, what version? If not, what version of the Couchbase Java SDK?

David Nault

The only dependencies I have regarding couchbase are the following:
implementation ‘org.springframework.boot:spring-boot-starter-data-couchbase’
implementation ‘com.fasterxml.jackson.datatype:jackson-datatype-joda:2.9.7’

The fasterxml.jackson.datatype dependency I just included right now in hopes that that was missing but no luck yet

Is it being de-serialized back into a org.joda.time.DateTime properly? Then it should be ok, right?
Unless you define your own converter, spring-data-couchbase relies on spring-data converters.

Does this StackOverflow post about Spring Boot Joda DateTime Serialisation help?