• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

NumberFormatException from DateFormat.parse() ???

 
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1.4.1_01
 
Tom Angioletti
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic