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
Starting from Elasticsearch 7 you should't use yyyy
but uuuu
. e.g:
@Field(type = FieldType.Date, format = DateFormat.custom, pattern = "uuuu-MM-dd'T'HH:mm:ss.SSSZZ")
private Date lastModifiedDate;
You don't need @JsonProperty
because now Spring Data Elasticsearch doesn't use Jackson but instead a MappingElasticsearchConverter. With this annotation, a converter is automatically created for this property and used.