File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes NumberFormatException from DateFormat.parse() ??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "NumberFormatException from DateFormat.parse() ???" Watch "NumberFormatException from DateFormat.parse() ???" New topic
Author

NumberFormatException from DateFormat.parse() ???

David Duran
Ranch Hand

Joined: Feb 11, 2002
Posts: 122
I'm getting this exception thrown sometimes, unfortunately I don't know the exact value that's getting passed to the parse method because the code is in a production environment. The calling code is pretty much:

According to the javadoc, parse() throws only ParseException yet strangely whatever argument is being passed to parse() is causing a NumberFormatException with the following message below.
Passing "" directly to parse() results in the appropriate ParseException: Exception in thread "main" java.text.ParseException: Unparseable date: ""
However, I don't know how to replicate the exception below. Any ideas?
java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Long.parseLong(Long.java:344)
at java.lang.Long.parseLong(Long.java:381)
at java.text.DigitList.getLong(DigitList.java:150)
at java.text.DecimalFormat.parse(DecimalFormat.java:1067)
at java.text.SimpleDateFormat.subParse(SimpleDateFormat.java:1381)
at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1159)
at java.text.DateFormat.parse(DateFormat.java:332)
Tom Angioletti
Greenhorn

Joined: Jun 25, 2001
Posts: 10
The exception gives exact line numbers, so we could take a look in the source code for the Java API. What version of Java are you running?
David Duran
Ranch Hand

Joined: Feb 11, 2002
Posts: 122
1.4.1_01
Tom Angioletti
Greenhorn

Joined: Jun 25, 2001
Posts: 10
Well I followed the stack trace from Long to DigitList but then got lost in DecimalFormat. It looks like the decimalAt field in DigitList must be 0 when Long.parseLong is called, but I don't know why.
I also noted that this area of the code was modified in Java 1.4.2. Maybe an upgrade would correct the problem or shed more light on it.
Sorry I'm not more help.
David Duran
Ranch Hand

Joined: Feb 11, 2002
Posts: 122
I've put in some logging to catch the exception and log the input. I'll post it if I find out.
Thanks for the input guys.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NumberFormatException from DateFormat.parse() ???