com.github.panchitoboy.common.rest.ObjectMapperProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-rest Show documentation
Show all versions of common-rest Show documentation
Libreria de ayuda la generacion de servicios REST
package com.github.panchitoboy.common.rest;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
@Provider
@Produces(MediaType.APPLICATION_JSON)
public class ObjectMapperProvider implements ContextResolver {
private final static DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
private final ObjectMapper objectMapper;
public ObjectMapperProvider() {
this.objectMapper = new ObjectMapper();
df.setTimeZone(TimeZone.getTimeZone("UTC"));
this.objectMapper.setDateFormat(df);
this.objectMapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
this.objectMapper.disable(MapperFeature.USE_GETTERS_AS_SETTERS);
}
@Override
public ObjectMapper getContext(Class> type) {
return objectMapper;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy