作者:雷雨点H | 来源:互联网 | 2023-09-25 18:11
代码中遇到这种错误,基本上是你的yyyyMMddHHmmss粗心大意写错了!
下面就是我的错误报告。
因为我的java代码中写错了:
错误代码如下
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(source);
更改之后:
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(source);
改成上面这个样子之后代码的问题就解决了!
参考:java.text.ParseException: Unparseable date: “” 这个是什么异常?
java.text.ParseException: Unparseable date: "2016-11-02 00-02-00"at java.text.DateFormat.parse(Unknown Source)at cn.itcast.ssm.controller.converter.CustomDateConverter.convert(CustomDateConverter.java:24)at cn.itcast.ssm.controller.converter.CustomDateConverter.convert(CustomDateConverter.java:1)at org.springframework.core.convert.support.GenericConversionService$ConverterAdapter.convert(GenericConversionService.java:329)at org.springframework.core.convert.support.ConversionUtils.invokeConverter(ConversionUtils.java:35)at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:169)at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:161)at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:450)at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:496)at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1099)at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:904)at org.springframework.beans.AbstractPropertyAccessor.setPropertyValues(AbstractPropertyAccessor.java:75)at org.springframework.validation.DataBinder.applyPropertyValues(DataBinder.java:699)at org.springframework.validation.DataBinder.doBind(DataBinder.java:595)at org.springframework.web.bind.WebDataBinder.doBind(WebDataBinder.java:191)at org.springframework.web.bind.ServletRequestDataBinder.bind(ServletRequestDataBinder.java:112)at org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor.bindRequestParameters(ServletModelAttributeMethodProcessor.java:153)at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:106)at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:77)at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:162)at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:123)at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:104)at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandleMethod(RequestMappingHandlerAdapter.java:746)at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:687)at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:915)at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:822)at javax.servlet.http.HttpServlet.service(HttpServlet.java:648)at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:796)at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624)at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783)at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:789)at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1437)at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)at java.lang.Thread.run(Unknown Source)