日期类型的字段为什么序列化的时候会有个 T (例如 2011-07-14T19:43:37 ),有什么讲究吗?在开发接口的时候,客户端开发人员收到这样的日期数据总要找来问问,怎么回事,能不能去掉?
1
qiyuey 2018-08-29 14:19:23 +08:00
|
2
calming 2018-08-29 14:56:14 +08:00
最简单的解决方案 T 和 Z 用“ ” replace 就完事了
|
3
laike9m 2018-08-29 15:01:11 +08:00
https://stackoverflow.com/questions/29281935/what-exactly-does-the-t-and-z-mean-in-timestamp
> The T doesn't really stand for anything. It is just the separator that the ISO 8601 combined date-time format requires. You can read it as an abbreviation for Time. The Z stands for the Zero timezone, as it is offset by 0 from the Coordinated Universal Time (UTC). |
4
zhengxiaowai 2018-08-29 15:52:52 +08:00
T 就是个分隔符别搭理他,现在一般也用空格代替。
|
5
yanaraika 2018-08-29 15:54:05 +08:00
如果提供接口的话,不要改,遵循 ISO8601 的来。让客户端 toLocaleDateString()去
|
6
amazonGo 2018-08-29 16:02:49 +08:00
用 String 或者 Long 类型替代
|
7
UnknownR 2018-08-29 16:17:25 +08:00
T 是 time separator,一般来说默认拿到的都是当前时区的时间,转成 UTC 的话会在末尾加上 Z,大部分都属于系统级的 feature,算是通俗规范定义,硬要拿掉也无所谓
It is in the form of yyyyMMddTHHmmssffffZ (case-sensitive, using a 4-digit year, 2-digit month, 2-digit day, the letter "T" as a time separator, 2-digit hour, 2-digit minute, 2-digit second, 4-digit millisecond, and the letter "Z" as the UTC indicator). An example of results when you use this format is 20150302T0840539947Z |
8
metrxqin 2018-08-29 16:34:57 +08:00
推荐使用 Timestamp 时间戳便于传输和运算,仅当需要展示时才转成字符串。
|