0

我有一个用 Java + MySql + Tomcat5 开发的系统。我曾经使用 Java6,但是我用 java7 将我的机器更新到了 win8,当我运行我的 servlet 时,我从 Tomcat 收到了这个错误。有谁知道为什么会发生这种情况或如何解决它。

javax.servlet.ServletException: java.lang.IllegalArgumentException: HOUR_OF_DAY: 0 -> 1
    at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2764)
    at java.util.Calendar.updateTime(Calendar.java:2606)
    at java.util.Calendar.getTimeInMillis(Calendar.java:1118)
    at java.util.Calendar.getTime(Calendar.java:1091)
    at com.genexus.GXutil.resetTime(Unknown Source)
    at com.genexus.db.driver.GXConnection.isNullDate(Unknown Source)
    at com.genexus.db.driver.GXResultSet.getGXDate(Unknown Source)
    at paddmwl__default.getResults(paddmwl.java:911)
    at com.genexus.db.DataStoreProvider.readNext(Unknown Source)
    at com.genexus.db.DataStoreProvider.execute(Unknown Source)
    at paddmwl.execute_int(paddmwl.java:44)
    at paddmwl.execute(paddmwl.java:30)
    at hconsola_impl.e202U2(hconsola_impl.java:3490)
    at hconsola_impl.evt2U2(hconsola_impl.java:478)
    at hconsola_impl.dispatchEvents(hconsola_impl.java:180)
    at hmasterpageww_impl.evtCH2(hmasterpageww_impl.java:215)
    at hmasterpageww_impl.wsCH2(hmasterpageww_impl.java:146)
    at hmasterpageww_impl.webExecute(hmasterpageww_impl.java:53)
    at hconsola_impl.webExecute(hconsola_impl.java:62)
    at com.genexus.webpanels.GXWebObjectBase.doExecute(Unknown Source)
    at hconsola.doExecute(hconsola.java:19)
    at com.genexus.webpanels.GXWebObjectStub.callExecute(Unknown Source)
    at com.genexus.webpanels.GXWebObjectStub.doPost(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:419)
    at org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:169)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
    at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
    at java.lang.Thread.run(Thread.java:722)

    com.genexus.webpanels.GXWebObjectStub.callExecute(Unknown Source)
    com.genexus.webpanels.GXWebObjectStub.doPost(Unknown Source)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    org.apache.catalina.servlets.InvokerServlet.serveRequest(InvokerServlet.java:419)
    org.apache.catalina.servlets.InvokerServlet.doPost(InvokerServlet.java:169)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

我现在知道为什么会发生这种情况,并且我没有从谷歌获得任何信息。谢谢你的帮助。祝你有美好的一天!!:)

4

1 回答 1

1

在巴西解析日期时,我看到由于 DST(夏令时)限制而引发了此异常。

由于 DST 限制,目前 GregorianCalendar 似乎正在抛出 IllegalArgumentException 。根据 GregorianCalendar,当 DB 驱动程序尝试读取日期字段时,存储的日期不是有效日期,因为时间部分为零(午夜)并且该特定日期没有午夜。

我知道这听起来很奇怪,但问题在于 DST 的定义方式(至少在巴西是这种情况,我不知道其他国家/地区),当我们进入 DST 时,时钟从午夜变为凌晨 1 点。这导致没有午夜的现象,因为它被 1am 代替,这导致了我们在这里看到的问题。在美国,我们没有这个问题,因为 DST 在凌晨 3 点改变,所以午夜总是在它应该在的地方。我想知道如何处理凌晨 3 点至凌晨 4 点的时间以避免这种怪癖。

我知道处理这个问题的唯一方法是永远不要存储时间部分为零的日期。

于 2013-11-11T20:18:59.920 回答