What the best ways to use decimals and datetimes with protocol buffers?

前端 未结 4 2028
后悔当初
后悔当初 2021-02-08 14:56

I would like to find out what is the optimum way of storing some common data type that were not included in the list supported by protocol buffers.

  • datetime (secon
4条回答
  •  北恋
    北恋 (楼主)
    2021-02-08 15:27

    For datetime with millisecond resolution I used an int64 that has the datetime as YYYYMMDDHHMMSSmmm. This makes it both concise and readable, and surprisingly, will last a very long time.

    For decimals, I used byte[], knowing that there's no better representation that won't be lossy.

提交回复
热议问题