File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes  java.lang.NumberFormatException.forInputString( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark " java.lang.NumberFormatException.forInputString(" Watch " java.lang.NumberFormatException.forInputString(" New topic


Noopur Kore
Ranch Hand

Joined: Aug 18, 2012
Posts: 77

at java.lang.NumberFormatException.forInputString(
at java.lang.Integer.parseInt(
at java.lang.Integer.parseInt(
at proservlet.Servlet1.doPost(
at javax.servlet.http.HttpServlet.service(
at javax.servlet.http.HttpServlet.service(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.valves.AccessLogValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$
java.lang.NumberFormatException: For input string: "- Year -"

How do I solve this error?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15082

According to the error message, you are trying to parse a string which contains "- Year -" as if it is an integer.

You ofcourse get an exception because there is no way to interpret "- Year -" as a valid number.

You have to check if the string contains a number, or catch the exception and do whatever needs to be done for your application when the string doesn't contain a valid number.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Stuart A. Burkett
Ranch Hand

Joined: May 30, 2012
Posts: 679
Noopur Kore wrote:java.lang.NumberFormatException: For input string: "- Year -"

How do I solve this error?

The code that is setting the value for the parameter is setting it to "- Year -" instead of the actual year, so that is what you need to fix.
I agree. Here's the link:
subject: java.lang.NumberFormatException.forInputString(
It's not a secret anymore!