我正在尝试将字符串时间戳转换为整数时间戳,并且我正在使用 postgres 作为数据库。
@Column(name = "connecte_timestamp")
private Integer timestamp;
SimpleDateFormat formater = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");
Date aujourdhui = new Date();
this.timestamp = Integer.parseInt(formater.format(aujourdhui)
.replace("-", "").replace(" ", "").replace(":", ""));
时间戳bigint
作为数据库中的一种类型。当我运行我的应用程序时,我得到以下堆栈跟踪:
java.lang.NumberFormatException:对于输入字符串:“01092013062024”在 java.lang.NumberFormatException.forInputString(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at java.lang.Integer.parseInt(Unknown Source) at com.forum.beans.Connecte.(Connecte.java:26) 在 com.forum.servlets.ListageForums.doGet(ListageForums.java:32) 在 javax.servlet.http.HttpServlet.service(HttpServlet.java:621) 在javax.servlet.http.HttpServlet.service(HttpServlet.java:728) 在 org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305) 在 org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain. java:210) 在 org.apache.catalina.core 的 org.apache.catalina.filters.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:108)。ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222) at org .apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123) 在 org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472) 在 org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve .java:171) 在 org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99) 在 org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953) 在 org.apache.catalina。 core.StandardEngineValve.invoke(StandardEngineValve.java:118) 在 org.apache.catalina.connector.CoyoteAdapter。org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589) at org.apache.coyote.AbstractProtocol 的服务(CoyoteAdapter.java:408) .tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(未知来源)concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source)
请问有什么帮助吗?