Giter Club home page Giter Club logo

Comments (2)

iseki0 avatar iseki0 commented on May 27, 2024 1

首先,不要在 JSON 中传递 Java 中的 Long;关于 JSON 的使用这边建议参考 RFC7493

An I-JSON sender cannot expect a receiver to treat an integer whose absolute value is greater than 9007199254740991 (i.e., that is outside the range [-(2 ** 53)+1, (2 ** 53)-1]) as an exact value.

其次,请不要尝试对 UNIX 时间戳进行直接的运算,各大语言都提供了非常方便的时间日期函数库,没有任何理由不用。关于数据库,一个实现良好的数据库不应该在这里体现出显著的性能差异。

传递时间戳需要考虑其它的问题,你的时间戳,是标准的 UNIX 时间戳吗,单位是秒还是毫秒?还是纳秒??起始时间是 1970-01-01T00:00:00Z 吗,关于闰秒呢,处理和 UNIX 时间戳一致吗(就是不处理,忽略)

当然阿里这手册中指出的传输格式也是问题严重,详细内容我在 #983 中指出了

from p3c.

zqq90 avatar zqq90 commented on May 27, 2024

补充楼上

  1. Long 在部分环境是有精度问题的
  2. 查询更直观
    • 比如数据库中:'2023-10-18T10:00:00Z' > '2023-10-18'
    • 比如日志中可以直接 grep '2023-10-18'
  3. 关于时区:
    • 部分数据库查询时,支持时区转换
    • 有些业务场景需要关注用户时区,保留用户时区
  4. 关于性能,代码是给人看的,在很多场景不需要扣这点儿性能
    另外,特殊优化的时间解析性能并没有那么差,理论上都是遍历一遍字符串,最终都是 64bit (根据精度)

from p3c.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.