DateValueBridge
is not the only piece of code involved in serializing dates to JSON. Hibernate Search does not just call toString()
to encode an Instant into JSON, because indeed, that would produce the wrong string (not the format expected by Elasticsearch).
DateValueBridge
converts a Date
to an Instant
. Hibernate Search then properly encodes it to JSON by applying a formatter.
Before you ask: no, it’s not currently possible to customize the date format that Hibernate Search uses for Instant
s; see [HSEARCH-2354] - Hibernate JIRA.