@Override public JodaDateDeserializerBase<?> withFormat(JacksonJodaDateFormat format) { return new LocalDateTimeDeserializer(format); }
return dt; throw ctxt.wrongTokenException(p, handledType(), JsonToken.END_ARRAY, "after LocalDateTime ints"); default: return (LocalDateTime) ctxt.handleUnexpectedToken(handledType(), p.getCurrentToken(), p, "expected String, Number or JSON Array");
return new LocalDateTime(jp.getLongValue()); case VALUE_STRING: DateTime local = parseLocal(jp); if (local == null) { return null;
@Provider @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public class ObjectMapperContextResolver implements ContextResolver<ObjectMapper> { final ObjectMapper mapper = new ObjectMapper(); public ObjectMapperContextResolver() { SimpleModule module = new SimpleModule(); module.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer()); module.addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer()); mapper.registerModule(module); // add JAXB annotation support if required mapper.registerModule(new JaxbAnnotationModule()); } @Override public ObjectMapper getContext(Class<?> type) { return mapper; } }
addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer()); addDeserializer(LocalDate.class, new LocalDateDeserializer()); addDeserializer(LocalTime.class, new LocalTimeDeserializer());
public JodaModule() { super(ModuleVersion.instance.version()); addDeserializer(DateMidnight.class, new DateMidnightDeserializer()); addDeserializer(LocalDateTime.class, new LocalDateTimeDeserializer()); addDeserializer(LocalDate.class, new LocalDateDeserializer()); addDeserializer(Period.class, new PeriodDeserializer()); addDeserializer(DateTime.class, DateTimeDeserializer.forType(DateTime.class)); addDeserializer(ReadableDateTime.class, DateTimeDeserializer.forType(ReadableDateTime.class)); addDeserializer(ReadableInstant.class, DateTimeDeserializer.forType(ReadableInstant.class)); // then serializers: addSerializer(DateTime.class, new DateTimeSerializer()); addSerializer(LocalDateTime.class, new LocalDateTimeSerializer()); addSerializer(LocalDate.class, new LocalDateSerializer()); addSerializer(DateMidnight.class, new DateMidnightSerializer()); addSerializer(Period.class, ToStringSerializer.instance); } }