ElasticSearch Spring-Data Date format always is long

后端 未结 4 703
Happy的楠姐
Happy的楠姐 2021-02-07 06:01

When using spring-data to insert Elasticsearch document with Date type, I can\'t get right date format, the date format always is Long.

here is the java code: Entity.jav

4条回答
  •  滥情空心
    2021-02-07 07:07

    Your mapping is created correctly. The problem is more likely to come from the Jackson JSON serializer. You should try adding this annotation to your date fields: @JsonFormat (shape = JsonFormat.Shape.STRING, pattern ="yyyy-MM-dd'T'HH:mm:ss.SSSZZ").

    There are also some alternative solutions that might better suit your case (i.e. creating a CustomDateSerializer, etc).

提交回复
热议问题