Jersey + Jackson JSON date format serialization - how to change the format or use custom JacksonJsonProvider

前端 未结 8 1157
花落未央
花落未央 2020-11-30 00:54

I am using Jersey + Jackson to provide REST JSON services layer for my application. The problem I have is that the default Date serialization format looks like that:

8条回答
  •  孤街浪徒
    2020-11-30 00:56

    json-io (https://github.com/jdereg/json-io) is a complete Java to / from JSON serialization library. When using it to write the JSON string, you can set how dates are formatted. By default, dates are written out as long (as above, which is milliseconds since Jan 1, 1970). However, you can give it a format String or Java DateFormatter and have the dates written in whatever format you wish.

提交回复
热议问题