ISO8601时间格式处理(2019-12-18T06:06:24.942Z)

本文解决项目中遇到的时间格式问题,详细解析ISO8601标准,包括SimpleDateFormat、Joda-Time及Apache-DateUtils的使用技巧,帮助开发者快速掌握不同库对ISO8601时间字符串的处理方法。

刚做项目,碰到时间处理的问题,格式就是2019-12-18T06:06:24.942Z。查阅了好多资料才搞定,记录下:

  1. SimpleDateFormat 解析ISO8601的格式串为 “yyyy-MM-dd’T’HH:mm:ss.SSSXXX”,其中XXX表示时区,与通用的ZZ不一样。

  2. Joda-Time 默认格式就是ISO8601,故可以直接用 new DateTime(…) 的方式直接解析ISO8601日期串,当然也可以用日期格式串来解析,用日期格式串解析日期的代码略长。

  3. Apache-DateUtils 解析ISO8601的格式串和Joda一样是 “yyyy-MM-dd’T’HH:mm:ss.SSSZZ”,解析代码相对Joda-Time更简洁。

只想说一句,这么设计的人脑子有坑吧,XXX表示时区,我真的是日了狗了。

另感谢下大神:https://www.jianshu.com/p/c54c4e945289

2025-11-18T12:05:42.328306Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:05:42.827563Z 0 [Warning] [MY-000000] [WSREP] P: last inactive check more than PT1.5S ago (PT1.50175S), skipping check 2025-11-18T12:05:43.329409Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:05:44.830680Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:05:46.330971Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:05:47.331809Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:05:48.333307Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:05:49.834612Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:05:50.835553Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:05:51.837049Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:05:53.338364Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:05:54.339654Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:05:55.340460Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:05:56.342368Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:05:57.343954Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:05:58.345140Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:05:59.346749Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:06:00.348116Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:06:01.349154Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:06:02.350898Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:06:03.352812Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:06:04.354223Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:06:05.355263Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:06:06.356815Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:06:07.358423Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:06:08.859917Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:06:09.861248Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:06:10.862332Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:06:11.863837Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:06:13.365377Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:06:14.366335Z 0 [System] [MY-000000] [WSREP] P: Failed to establish connection: Connection refused 2025-11-18T12:06:14.371047Z 0 [System] [MY-000000] [WSREP] P: PC protocol downgrade 1 -> 0 2025-11-18T12:06:14.371084Z 0 [System] [MY-000000] [WSREP] P: view((empty)) 2025-11-18T12:06:14.371338Z 0 [ERROR] [MY-000000] [WSREP] P: failed to open gcomm backend connection: 110: failed to reach primary view at /builddir/build/BUILD/galera-26.4.22/gcomm/src/pc.cpp:connect():160 2025-11-18T12:06:14.371372Z 0 [ERROR] [MY-000000] [WSREP] P: /builddir/build/BUILD/galera-26.4.22/gcs/src/gcs_core.cpp:gcs_core_open():259: Failed to open backend connection: -110 (Connection timed out) 2025-11-18T12:06:15.372458Z 0 [ERROR] [MY-000000] [WSREP] P: /builddir/build/BUILD/galera-26.4.22/gcs/src/gcs.cpp:gcs_open():1707: Failed to open channel 'galera' at 'gcomm://galera02': -110 (Connection timed out) 2025-11-18T12:06:15.372598Z 0 [ERROR] [MY-000000] [WSREP] P: gcs connect failed: Operation timed out 2025-11-18T12:06:15.372630Z 0 [ERROR] [MY-000000] [WSREP] wsrep::connect(gcomm://galera02) failed: 7 2025-11-18T12:06:15.372649Z 0 [ERROR] [MY-010119] [Server] Aborting 2025-11-18T12:06:15.372671Z 0 [System] [MY-000000] [WSREP] P: dtor state: CLOSED 解析
最新发布
11-19
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值