camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ron Anderson <>
Subject Re: MongoDB Jackson Date Mapping Option
Date Sat, 16 Feb 2013 00:13:44 GMT
Thanks so much for your help - For anyone else trying to solve this I'll show
what I ended up doing that worked to map a Java date to a Bson date or
ISODate in MongoDB.

Created a custom serializer class:

public class BsonDateSerializer extends JsonSerializer<Date>{

public void serialize(Date value, JsonGenerator jgen, SerializerProvider
provider) throws IOException,     JsonProcessingException {
            serializeContents(value, jgen, provider);

private void serializeContents(Date value, JsonGenerator jgen,
SerializerProvider provider) throws IOException {
	SimpleDateFormat formatter = new
        String formattedDate = formatter.format(value);

Annotated my pojo to use custom serializer:

@JsonSerialize(using = BsonDateSerializer.class)
public Date getStartTime() {
	return startTime;

And the Mongo route was already working but repeated here:



View this message in context:
Sent from the Camel - Users mailing list archive at

View raw message