在将爬下来的网页解析需要的字段批量入口的时候(逻辑类似下面):

@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报时区异常错误的更多相关文章

  1. 3.Sprint 代理对象与原始对象的异常错误

    代码案例分析 Service层添加了注解@Transactional @Service @Transactional public class CustomerService extends Base ...

  2. [转载]IIS7报500.23错误的解决方法

    原文出处: 原文作者:pizibaidu 原文链接:http://pizibaidu.blog.51cto.com/1361909/1794446 背景:今天公司终端上有一个功能打开异常,报500错误 ...

  3. 总结Selenium自动化测试方法(六)常见的异常错误处理

    六.常见的异常错误处理 NoSuchElementException: Message: Unable to locate element: {"method":"xpa ...

  4. Java异常错误的面试题及答案

    1) Java中什么是Exception? 这个问题经常在第一次问有关异常的时候或者是面试菜鸟的时候问.我从来没见过面高级或者资深工程师的 时候有人问这玩意,但是对于菜鸟,是很愿意问这个的.简单来说, ...

  5. Tomcat正常启动,访问所有页面均报404异常,404异常总结

    今天遇到一个问题:Tomcat正常启动,访问所有页面均报404异常 404异常,很常见,大多情况是路径错误.web.xml文件映射路径写错.服务器设置.servlet的jar包未导进去或者没有随项目发 ...

  6. 【maven】【IDEA】idea中使用maven编译项目,报错java: 错误: 找不到符号 【2】

    =================================================================================== idea中使用maven编译项目 ...

  7. 【Azure App Service】C#下制作的网站,所有网页本地测试运行无误,发布至Azure之后,包含CHART(图表)的网页打开报错,错误消息为 Runtime Error: Server Error in '/' Application

    问题描述 C#下制作的网站,所有网页本地测试运行无误,发布至Azure之后,包含CHART(图表)的网页打开报错,错误消息为 Runtime Error: Server Error in '/' Ap ...

  8. Ceph RGW服务 使用s3 java sdk 分片文件上传API 报‘SignatureDoesNotMatch’ 异常的定位及规避方案

    import java.io.File;   import com.amazonaws.AmazonClientException; import com.amazonaws.auth.profile ...

  9. MVC3在IIS7.5发布(部署)报403.14错误的解决办法

    MVC3在IIS7.5发布(部署)报403.14错误的解决办法     错误现象: 报403.14 forbidden错误 web服务器被配置为不列出此目录的内容. 解决办法: 检查站点的处理程序映射 ...

随机推荐

  1. Jmeter 快速入门--简单的http压测

    1.添加线程组 打开jmeter主窗口后,选择左侧树形结构里的"测试计划",然后右键选择添加,选择"threads(users)",选择"线程组&qu ...

  2. IE 之 userData 模拟 localStorage

    引 chrome,  safari, firefox, ie 9都支持 localStorage.  但可恶的是,中国 ie 6 占有最大的比例. 使用 cookie 不但容量有限,而且给我们增加了不 ...

  3. ZooKeeper系列文章

    ZooKeeper FAQ ZooKeeper客户端事件串行化处理 ZooKeeper分布式锁避免羊群效应(Herd Effect) ZooKeeper管理员指南——部署与管理ZooKeeper Zo ...

  4. 【Linux笔记】CentOS yum 安装 vsftpd

    vsftpd是一款在Linux发行版中最受推崇的FTP服务器程序.特点是小巧轻快,安全易用,下面直接上干货. 一.安装vsftp 以管理员的身份使用yum命令安装vsftp: [root@localh ...

  5. 第78天:jQuery事件总结(一)

    jQuery事件总结(一)    现在就一点一点积累自己的知识体系,记录自己学到的和自己所理解的jQuery. JavaScript和HTML之间的交互式通过用户和浏览器操作页面时引发的事件机制来处理 ...

  6. hdu6415 Rikka with Nash Equilibrium (DP)

    题目链接 Problem Description Nash Equilibrium is an important concept in game theory. Rikka and Yuta are ...

  7. NoSQL - Redis应用场景

         问题的引入 DB(Oracle.MySQL.Postgresql等)+Memcached 这种架构模式在我们生产环境中十分常见,一般我们通过Memcached将热点数据加载到cache,应用 ...

  8. CGLib动态代理引起的空指针异常

    一个同事将公司的开发框架基于最新的Spring.Tomcat.Java版本作了部分修改,拿来开发运行之后,发现一个奇怪的空指针异常. 还原一下当时的场景,代码大概如下,所有的Servlet继承自Bas ...

  9. 抽屉点赞及jQuery CSS操作

    1.需要用到的知识点: CSS处理 $('t1').css('color','red') 点赞: -$('t1').append() -$('t1').remove() -setInterval -o ...

  10. Coding and Paper Letter(四十五)

    资源整理. 1 Coding: 1.Python库gempy,一种基于Python的开源三维结构地质建模软件,它允许从界面和方向数据隐式(即自动)创建复杂的地质模型. 它还支持随机建模以解决参数和模型 ...