0

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.And this happens not for all server platforms.

Many thanks in advance.

Mark Carmark
  • 167
  • 4
  • 11
  • If you add this System.out.println(Locale.getDefault()); to the different servers, what do you get? I suspect you have different locales on your servers and this produces the different number formats. – Gunslinger Aug 20 '13 at 10:04

1 Answers1

0

Try formatting the number like this:

String.format(Locale.US, "%d", value.toDateTimeAtStartOfDay().getMillis())

This will use exactly that pattern.

Gunslinger
  • 729
  • 1
  • 9
  • 19