Search code examples
avro

What is the best practice of code Date field in Apache Avro as of now?


I have been searching around and saw the jira https://issues.apache.org/jira/browse/AVRO-739 for this matter, but I don't have a better sense of what avro support for date time within the user document. What I trying to achieve is to code the date with timezone information (with iso8601) from the kafka producer side in python and all the downstream consumers are written in java can decode it properly. what is the best practice for this?


Solution

  • The best practice is to simply encode the number of seconds/milliseconds since 1970-01-01 UTC, also known as Unix or Epoch time, and then convert to whatever timezone you want on the client side. This has been the only sane approach that worked for me over the years.