This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NumberFormatException from DateFormat.parse() ???

 
David Duran
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.4.1_01
 
Tom Angioletti
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic