com.jrodeo.bson.marshallers.DateMarshaller Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bson-marshaller Show documentation
Show all versions of bson-marshaller Show documentation
A tool to create Java marshallers to and from bson. Currently used in a data access
layer serialize Json to Bson for MongoDB storage.
package com.jrodeo.bson.marshallers;
import org.bson.BsonReader;
import org.bson.BsonWriter;
import java.util.Date;
/**
* A hand coded Marshaller
to serialize java.util.Date
.
*/
public class DateMarshaller extends AbstractSimpleMarshaller {
@Override
public Class getForClass() {
return Date.class;
}
public void write(BsonWriter writer, Date value) {
writer.writeDateTime(value.getTime());
}
public Date read(BsonReader reader) {
long l = reader.readDateTime();
return new Date(l);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy