JodaTime报时区异常错误
在将爬下来的网页解析需要的字段批量入口的时候(逻辑类似下面):
@Test
public void test_001(){ String TIME = "1990-04-15";
DateTime dateTime = DateTime.parse(TIME);
System.out.println(dateTime); }
程序抛出了一个时区异常:
org.joda.time.IllegalInstantException: Cannot parse "1990-04-15": Illegal instant due to time zone offset transition (Asia/Shanghai) at org.joda.time.format.DateTimeParserBucket.computeMillis(DateTimeParserBucket.java:471)
at org.joda.time.format.DateTimeParserBucket.computeMillis(DateTimeParserBucket.java:411)
at org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:928)
at org.joda.time.DateTime.parse(DateTime.java:160)
at org.joda.time.DateTime.parse(DateTime.java:149)
at org.cc11001100.Test_001.test_001(Test_001.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
这个是因为我们设置的时区不是东八区,所以解析的时候不应该使用DateTime而应该使用LocalDateTime:
@Test
public void test_001(){ String TIME = "1990-04-15";
// DateTime dateTime = DateTime.parse(TIME);
// System.out.println(dateTime); LocalDateTime localDateTime = LocalDateTime.parse(TIME);
System.out.println(localDateTime); }
使用LocalDateTime时会识别使用当前所在的时区。
。
JodaTime报时区异常错误的更多相关文章
- 3.Sprint 代理对象与原始对象的异常错误
代码案例分析 Service层添加了注解@Transactional @Service @Transactional public class CustomerService extends Base ...
- [转载]IIS7报500.23错误的解决方法
原文出处: 原文作者:pizibaidu 原文链接:http://pizibaidu.blog.51cto.com/1361909/1794446 背景:今天公司终端上有一个功能打开异常,报500错误 ...
- 总结Selenium自动化测试方法(六)常见的异常错误处理
六.常见的异常错误处理 NoSuchElementException: Message: Unable to locate element: {"method":"xpa ...
- Java异常错误的面试题及答案
1) Java中什么是Exception? 这个问题经常在第一次问有关异常的时候或者是面试菜鸟的时候问.我从来没见过面高级或者资深工程师的 时候有人问这玩意,但是对于菜鸟,是很愿意问这个的.简单来说, ...
- Tomcat正常启动,访问所有页面均报404异常,404异常总结
今天遇到一个问题:Tomcat正常启动,访问所有页面均报404异常 404异常,很常见,大多情况是路径错误.web.xml文件映射路径写错.服务器设置.servlet的jar包未导进去或者没有随项目发 ...
- 【maven】【IDEA】idea中使用maven编译项目,报错java: 错误: 找不到符号 【2】
=================================================================================== idea中使用maven编译项目 ...
- 【Azure App Service】C#下制作的网站,所有网页本地测试运行无误,发布至Azure之后,包含CHART(图表)的网页打开报错,错误消息为 Runtime Error: Server Error in '/' Application
问题描述 C#下制作的网站,所有网页本地测试运行无误,发布至Azure之后,包含CHART(图表)的网页打开报错,错误消息为 Runtime Error: Server Error in '/' Ap ...
- Ceph RGW服务 使用s3 java sdk 分片文件上传API 报‘SignatureDoesNotMatch’ 异常的定位及规避方案
import java.io.File; import com.amazonaws.AmazonClientException; import com.amazonaws.auth.profile ...
- MVC3在IIS7.5发布(部署)报403.14错误的解决办法
MVC3在IIS7.5发布(部署)报403.14错误的解决办法 错误现象: 报403.14 forbidden错误 web服务器被配置为不列出此目录的内容. 解决办法: 检查站点的处理程序映射 ...
随机推荐
- 【第八周】【新蜂】新NABCD
由小组成员宫成荣撰写 一.小组项目申请时提交的NABCD: 痛点:普通的俄罗斯方块是不现实距离下一级有多远的,我们的游戏能显示距离下一等级游戏有多远.方便玩家体验. nabc: n:能满足大多数玩家的 ...
- MySql中的varchar类型
转载:http://www.cnblogs.com/doit8791/archive/2012/05/28/2522556.html 1.varchar类型的变化 MySQL 数据库的varchar类 ...
- Redis 备份数据的两种方式
既然是数据库,那就一定有数据备份方式了,而且 Redis 是内存形式的数据库,更需要数据备份了,要不然断电数据就全都丢失了. Redis 数据备份有两种方式: RDB(数据快照) AOF(记录操作日志 ...
- Maven 项目依赖 pom 文件模板
下面是网上down的 pom 文件模板: <!-- 属性 --> <properties> <spring.version>4.2.4.RELEASE</sp ...
- HDU4810_Wall Painting
题目很简单. 给你n个数,输出n个答案,第i个答案表示从n个数里取遍i个数的异或值的和. 其实每一个数最多也就32位,把所有的数分解,保存每一位总共有多少个1,最后要是这一位的异或结果为1,那么在所有 ...
- HDU 3579——Hello Kiki
好久没写什么数论,同余之类的东西了. 昨天第一次用了剩余定理解题,今天上百度搜了一下hdu中国剩余定理.于是就发现了这个题目. 题目的意思很简单.就是告诉你n个m[i],和n个a[i].表示一个数对m ...
- [您有新的未分配科技点]数位DP:从板子到基础(例题 bzoj1026 windy数 bzoj3131 淘金)
只会统计数位个数或者某种”符合简单规律”的数并不够……我们需要更多的套路和应用 数位dp中常用的思想是“分类讨论”思想.下面我们就看一道典型的分类讨论例题 1026: [SCOI2009]windy数 ...
- 使用StoryBoard执行动画
在WPF动画编程中,最常用的动画处理方式是DoubleAnimation动画,但是随着你的开发经验越来越多,你会发现,有时候使用这个动画类会很麻烦,因为这个动画是封闭动画,也就是说在动画的时间间隔内, ...
- 【BZOJ4912】天才黑客(最短路,虚树)
[BZOJ4912]天才黑客(最短路,虚树) 题面 BZOJ 洛谷 题解 \(Anson\)爷讲过的题目,然而我还是不会做 只有照着\(zsy\)的程序打我才会做....果然太弱了. 这道题目显然是把 ...
- 微软.NET Framework cve-2017-8759 复现
0x00 漏洞前言 FireEye公司最近发现一份恶意微软Office RTF文档,其中利用到一项SOAP WSDL解析器代码注入漏洞——编号CVE-2017-8759.该漏洞允许恶意人士在解析SOA ...