Search in sources :

Example 1 with DateAndTime

use of com.google.api.server.spi.types.DateAndTime in project endpoints-java by cloudendpoints.

the class ServletResponseResultWriter method getWriteDateAndTimeAsStringModule.

private static SimpleModule getWriteDateAndTimeAsStringModule() {
    JsonSerializer<DateAndTime> dateAndTimeSerializer = new JsonSerializer<DateAndTime>() {

        @Override
        public void serialize(DateAndTime value, JsonGenerator jgen, SerializerProvider provider) throws IOException {
            jgen.writeString(value.toRfc3339String());
        }
    };
    SimpleModule writeDateAsStringModule = new SimpleModule("writeDateAsStringModule", new Version(1, 0, 0, null, null, null));
    writeDateAsStringModule.addSerializer(DateAndTime.class, dateAndTimeSerializer);
    return writeDateAsStringModule;
}
Also used : Version(com.fasterxml.jackson.core.Version) DateAndTime(com.google.api.server.spi.types.DateAndTime) JsonGenerator(com.fasterxml.jackson.core.JsonGenerator) JsonSerializer(com.fasterxml.jackson.databind.JsonSerializer) SerializerProvider(com.fasterxml.jackson.databind.SerializerProvider) SimpleModule(com.fasterxml.jackson.databind.module.SimpleModule)

Aggregations

JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)1 Version (com.fasterxml.jackson.core.Version)1 JsonSerializer (com.fasterxml.jackson.databind.JsonSerializer)1 SerializerProvider (com.fasterxml.jackson.databind.SerializerProvider)1 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)1 DateAndTime (com.google.api.server.spi.types.DateAndTime)1