Tuesday, 20 August 2013

Spring MVC REST JsonSerializer serialize long in exponential notation format

Spring MVC REST JsonSerializer serialize long in exponential notation format

There is custom Json serializer(for ObjectMapper) in my Spring MVC REST
application:
public class DateSerializer extends JsonSerializer<LocalDate>
{
public LocalDateSerializer()
{
super();
}
@Override
public void serialize(LocalDate value, JsonGenerator jgen,
SerializerProvider provider) throws IOException
{
if (value != null)
{
jgen.writeNumber(value.toDateTimeAtStartOfDay().getMillis());
}
}
}
and service returns json representation of this field with exponential
notation format e.g. 1.377216E12 instead of normal timestamp format
Many thanks in advance.

No comments:

Post a Comment