algolia / algoliasearch-client-java

⚡️ A fully-featured and blazing-fast Java API client to interact with Algolia.
https://www.algolia.com/doc/api-client/getting-started/install/java/
MIT License
47 stars 33 forks source link

fix(rules): custom serialization for `TimeRange` #745

Closed aallam closed 3 years ago

aallam commented 3 years ago
Q A
Bug fix? yes
New feature? no
BC breaks? no
Need Doc update no

Describe your change

Specify custom serialization for TimeRange, using Unix timestamps in seconds.

What problem is this fixing?

Rule's validity time ranges (from, until) only support integer Unix timestamps in seconds. The client's Jackson configuration serializes/deserializes those values using millisecond timestamps. From Jackson's JavaTimeModule:

For serialization, timestamps are written as fractional numbers (decimals), where the number is seconds and the decimal is fractional seconds, (...) If WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS is disabled, timestamps are written as a whole number of milliseconds.