How do I configure the date formatter through Genson/Jersey?

六月ゝ 毕业季﹏ 提交于 2019-12-01 22:26:26
eugen

To configure Genson instances you can use Genson.Builder class (it is similar to Gson on this point). Then you have to inject it with Jersey.

@Component
@Provider
public class GensonProvider implements ContextResolver<Genson> {
   private final Genson genson = new Genson.Builder().setDateFormat(yourDateFormat).create();

    @Override
   public Genson getContext(Class<?> type) {
     return genson;
   }
}

You might also want to have a look at how Genson is integrated into Jersey here.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!