Exception when Parsing Dates in Java
<p><strong>Edited in accordance with comments</strong></p>

<p>For some reason, I seem to be getting this exception <em>randomly</em> occurring when I am trying to parse between <code>Date</code> and <code>String</code> formats in Java.</p>

<p>Here is a snippet of the code I’ve got (this is just for testing purposes):</p>

<pre><code>SimpleDateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
for(...){
  ...
   System.out.println("Before parsing: [" + lastEntryDate + "]");
   Date date = formatter.parse(lastEntryDate);
   System.out.println("After parsing: [" + date + "]”);
}
</code></pre>

<p>And the output:</p>

<pre><code>Before parsing: [Sun Aug 07 22:45:30 EST 2011]
After parsing: [Sun Aug 07 22:45:30 EST 2011]
Before parsing: [Sun Aug 07 22:45:31 EST 2011]
After parsing: [Sun Aug 07 22:45:31 EST 2011]
Before parsing: [Sun Aug 07 22:45:31 EST 2011]
After parsing: [Sun Aug 07 22:45:31 EST 2011]
Before parsing: [Sun Aug 07 22:45:31 EST 2011]
After parsing: [Sun Aug 07 22:45:31 EST 2011]
Before parsing: [Sun Aug 07 22:45:31 EST 2011]
After parsing: [Sun Aug 07 22:45:31 EST 2011]
Before parsing: [Sun Aug 07 22:45:31 EST 2011]
java.lang.NumberFormatException: For input string: ""
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    at java.lang.Long.parseLong(Long.java:431)
    at java.lang.Long.parseLong(Long.java:468)
    at java.text.DigitList.getLong(DigitList.java:177)
    at java.text.DecimalFormat.parse(DecimalFormat.java:1298)
    at java.text.SimpleDateFormat.subParse(SimpleDateFormat.java:1936)
    at java.text.SimpleDateFormat.parse(SimpleDateFormat.java:1312)
    at java.text.DateFormat.parse(DateFormat.java:335)
    at proj01.servicebus.ServiceBus.writeFeedEntry(ServiceBus.java:211)
    at proj01.servicebus.ServiceBus.writeFeedEntries(ServiceBus.java:243)
    at proj01.servicebus.ServiceBus.access$1(ServiceBus.java:241)
    at proj01.servicebus.ServiceBus$1.call(ServiceBus.java:84)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:680)
</code></pre>

<p>The problem is:</p>

<ul>
<li>sometimes, the parsing fails ?! (see for example, where it gives 00:00:00)</li>
<li>sometimes, the exception shown is thrown ?!</li>
<li>the problem seems to be random!</li>
</ul>

<p>What is the likely cause and solution to this problem?</p>
