Cannot parse "1986-05-04": Illegal instant due to time zone offset transition (Asia/Shanghai)
调查系统错误时,发现了一个很奇怪的现象,出生日期1986-05-04号的用户始终无法注册。发现后台使用使用jodatime的代码demo如下:
public static DateTime parseDatetime(String time, String format) {
DateTimeFormatter formatter = DateTimeFormat.forPattern(format);
return formatter.parseDateTime(time);
}
后台抛出了异常:
Exception in thread "main" org.joda.time.IllegalInstantException: Cannot parse "1986-05-04": Illegal instant due to time zone offset transition (Asia/Shanghai)
at org.joda.time.format.DateTimeParserBucket.computeMillis(DateTimeParserBucket.java:390)
at org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:854)
at cn.com.lawson.web.T.parseDatetime(T.java:14)
at cn.com.lawson.web.T.main(T.java:9)
感觉非常的疑惑,怎么这个日期会有问题呢?于是百度后:http://www.bubuko.com/infodetail-997580.html 在这个页面上找到的原因,原来是夏令,冬令的日期导致的
详情可以可以打开网页研究研究。
解决办法:
1、使用UTC时间
public static DateTime parseDatetime(String time, String format) {
DateTimeFormatter formatter = DateTimeFormat.forPattern(format).withZoneUTC();
return formatter.parseDateTime(time);
}
2、使用本地时区转换
public static LocalDateTime parseDatetime(String time, String format) {
DateTimeFormatter formatter = DateTimeFormat.forPattern(format);
return formatter.parseLocalDateTime(time);
}
Cannot parse "1986-05-04": Illegal instant due to time zone offset transition (Asia/Shanghai)的更多相关文章
- Illegal instant due to time zone offset transition (Asia/Shanghai)_夏令时问题
项目报错信息: Connot parse "1991-04-14",illegal instant due to time zone offset transition(Asia/ ...
- kFreeBSD 7.0于2013/05/04发布 桌面环境 GNOME 3....
kFreeBSD 7.0于2013/05/04发布 桌面环境 GNOME 3.4, KDE 4.8.4, Xfce 4.8, and LXDE
- .WrongArgumentException: Malformed database URL, failed to parse the connection string near ';characterEncoding=UTF-8&;serverTimezone=Asia/Shanghai'.)
连接mysql库报的异常信息: org.springframework.transaction.CannotCreateTransactionException: Could not open JDB ...
- 2016.05.04,英语,《Vocabulary Builder》Unit 22
acerb/acri: comes from the Latin adjective acer, meaning 'sharp' or 'sour'. acerbic: [ə'sɜːrbɪk] adj ...
- 2017/05/04 java 基础 随笔
1.java变量在使用之前必须初始化 int a; a=10 ; int b; 没有初始化,也没有使用也不报错 2.强制类型转换 int a=8: byte b=6; b=(byte)(a+b); ...
- EZ 2018 05 04 NOIP2018 模拟赛(十二)
这次的试卷应该是激励我们一下的,链接 然后大家的分数就都很高,然后我就210被一群秒A T2的240大佬爆踩 掉了5rating但Rank竟然发杀了 X_o_r dalao && YZ ...
- C++课堂作业2016.05.04
GitHub/object-oriented 作业题目 开课后的第一次作业,简单地写了一个类,用成员函数来实现计算圆的面积. [代码] main.cpp #include "Area.h&q ...
- 2015.05.04,外语,读书笔记-《Word Power Made Easy》 14 “如何谈论日常现象” SESSION 41
1. people are the craziest animals bovine(['bәuvain] adj. (似)牛的, 迟钝的),像牛一样placid(['plæsid] adj. 安静的, ...
- Fitness - 05.04
倒计时241天 运动38分钟,共计9组.拉伸10分钟. 每组跑步2分钟(6.3KM/h),走路2分钟(6KM/h). 上午下了课,直奔健身房. 手机坏了,没有听音乐. 没有吃午饭,但是上午喝的咖啡还是 ...
随机推荐
- srt字幕翻译
需要把字幕名改成i.txt 有有道和谷歌 代码: #Author:Chenglong Qian #Copyright :Chenglong Qian import json import reques ...
- s3cmd s3命令行工具
Amazon S3 Tools: Command Line S3 Client Software and S3 Backup 官方网站
- python os模块判断文件是否存在
import os os.path.exists(test_file.txt)
- pytorch 手写数字识别项目 增量式训练
dataset.py ''' 准备数据集 ''' import torch from torch.utils.data import DataLoader from torchvision.datas ...
- 作业3-k均值算法
4. 作业: 1). 扑克牌手动演练k均值聚类过程:>30张牌,3类 2). *自主编写K-means算法 ,以鸢尾花花瓣长度数据做聚类,并用散点图显示.(加分题) 3). 用sklearn.c ...
- Zabbix3.0安装部署最佳实践
Zabbix介绍 1.1zabbix 简介 Zabbix 是一个高度集成的网络监控解决方案,可以提供企业级的开源分布式监控解决方案,由一个国外的团队持续维护更新,软件可以自由下载使用,运作团队靠提供收 ...
- Vue tools开发工具报错Cannot read property '__VUE_DEVTOOLS_UID__' of undefined
使用 vue tools 开发工具,不显示调试面板中的组件,点击控制台报错: Cannot read property 'VUE_DEVTOOLS_UID' of undefined 在 main.j ...
- Qt之QListWidget:项目的多选与单选设置
2019独角兽企业重金招聘Python工程师标准>>> #include "widget.h" #include <QApplication> #in ...
- 墨仓式进入2.0时代?爱普生商用墨仓式L4158试用
提起"墨仓式"打印机,相信现在已经没有人需要过多的解释,墨仓式打印机在打印市场占有率不断提高就是最佳佐证.为什么用户对于墨仓式这么认可,想必是墨仓式真正洞悉了他们的需求,解决了打印 ...
- JAVA第一次blog总结
JAVA第一次blog总结 0.前言 大一下学期我们开展了OPP这门课程,这也是我们第一次接触到JAVA.与上学期我们在学校里学C语言不同的是,这学期由于疫情原因我们是以网课的方式在学习.在学习中我发 ...