日期类型的字段为什么序列化的时候会有个 T(例如 2011-07-14T19:43:37),有什么讲究吗 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
请不要在回答技术问题时复制粘贴 AI 生成的内容
daijinming

日期类型的字段为什么序列化的时候会有个 T(例如 2011-07-14T19:43:37),有什么讲究吗

  •  
  •   daijinming Aug 29, 2018 3080 views
    This topic created in 2809 days ago, the information mentioned may be changed or developed.

    日期类型的字段为什么序列化的时候会有个 T (例如 2011-07-14T19:43:37 ),有什么讲究吗?在开发接口的时候,客户端开发人员收到这样的日期数据总要找来问问,怎么回事,能不能去掉?

    8 replies    2018-08-29 16:34:57 +08:00
    calming
        2
    calming  
       Aug 29, 2018
    最简单的解决方案 T 和 Z 用“ ” replace 就完事了
    laike9m
        3
    laike9m  
       Aug 29, 2018
    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).
    zhengxiaowai
        4
    zhengxiaowai  
       Aug 29, 2018
    T 就是个分隔符别搭理他,现在一般也用空格代替。
    yanaraika
        5
    yanaraika  
       Aug 29, 2018
    如果提供接口的话,不要改,遵循 ISO8601 的来。让客户端 toLocaleDateString()去
    amazonGo
        6
    amazonGo  
       Aug 29, 2018
    用 String 或者 Long 类型替代
    UnknownR
        7
    UnknownR  
       Aug 29, 2018
    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
    metrxqin
        8
    metrxqin  
       Aug 29, 2018
    推荐使用 Timestamp 时间戳便于传输和运算,仅当需要展示时才转成字符串。
    About     Help     Advertise     Blog     API     FAQ     Solana     4059 Online   Highest 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 63ms UTC 05:07 PVG 13:07 LAX 22:07 JFK 01:07
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86