Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Date.parse fails

807606Apr 5 2007 — edited Apr 5 2007
Hi

I have a small java program that I use unce a month to sift through a file in a CSV format to produce a report of the data.

End of Feb07 I used the program with no problems. Since then there have been absolutely no changes to the code whatsoever. Now I try to execute the program on a file for the end of March where the format remains correct and I find that it does not work.

The bit of code where things fall over looks like this:
public int TimeDiff(String StartDate, String EndDate){
	
final long ONE_HOUR = 60*60*1000L;
int datediff = (int)((Date.parse(EndDate) - Date.parse(StartDate))/(24*ONE_HOUR));
return datediff;
}
I pass in 2 dates extracted from the CSV file in a string format, parse the dates, calculate the time between each, cast to an int and pass it back.

Used to work perfect! and literally overnight has stopped...

I've tried this on several different machines and thouroughly checked that the strings passed into the functions are correct immediately before the line that begins
int datediff =  (int)
by writing their values to the console.

I'm reluctant to try changing the code to a different approach because I know this code always worked before - it still compiles perfectly too.

The error I get looks like this:


java.lang.ArrayIndexOutOfBoundsException: 0
at ScoreCard.DataPull.readfile(DataPull.java:126)
at ScoreCard.gui.actionPerformed(gui.java:88)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)


Anyone have ideas to the cause - has there been some update to the Java environment or Windows XP during the past month that could have caused this??

Thanks in advance to anyone who can help!

Cheers,

Phil.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 3 2007
Added on Apr 5 2007
9 comments
532 views