Comments (2)
首先,不要在 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.
补充楼上
- Long 在部分环境是有精度问题的
- 查询更直观
- 比如数据库中:
'2023-10-18T10:00:00Z' > '2023-10-18'
- 比如日志中可以直接 grep '2023-10-18'
- 比如数据库中:
- 关于时区:
- 部分数据库查询时,支持时区转换
- 有些业务场景需要关注用户时区,保留用户时区
- 关于性能,代码是给人看的,在很多场景不需要扣这点儿性能
另外,特殊优化的时间解析性能并没有那么差,理论上都是遍历一遍字符串,最终都是 64bit (根据精度)
from p3c.
Related Issues (20)
- 数组下标越界 HOT 1
- 提几条日常编码时的想法供参考
- 2023.2版本插件报错 HOT 13
- 有没有web的开发手册开发规范
- 规约中有关前后端接口日期时间传递的约定是在挖大坑 HOT 8
- URL Broker 指的是什么
- beta版本试用,增加了对Record类的检测,优化了Switch中default块的判断 HOT 2
- How to add a new rule HOT 69
- stream和enum的格式化能不能优化下
- idea 2023.1.5版本安装规约插件代码规约失效 HOT 1
- How can I use my custom rule which is similar to defined rule? HOT 1
- LockShouldWithTryFinallyRule规则不生效
- 请问下这个插件是没更新了吗? HOT 3
- 类名使用 UpperCamelCase 风格,但以下情形例外:DO / / BO / / DTO / VO / AO / PO / UID 等。这个规则不生效。
- P3C的阿里巴巴网址无法拉取包了
- 这个插件是否已经不维护了
- Gitlab集成P3C检查,如何只对增量代码做检查
- 实时检测功能开启后不生效 HOT 1
- 实时检测功能开启后不生效
- java.lang.ArrayIndexOutOfBoundsException HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p3c.