Originally Posted by
royroy7
hi
for (int i = 0; i < nodeCount; i++) {
// Problem might start from here, are they the real thing you are expecting to get?
String venue = xPath.evaluate("Venue", nodes.item(i));
Date startDate = Date.valueOf(xPath.evaluate("StartDate", nodes.item(i))); //line 1
Date endDate = Date.valueOf(xPath.evaluate("EndDate", nodes.item(i))); //line 2
//
Event ev = new Event(venue,startDate,endDate);
list.add(ev);
}
Correct me if I am wrong: You should getting an IllegalArgumentException.
1. Think of this, when
i=0, what string will you get from
xPath.evaluate("StartDate", nodes.item(i))? And, what will you get when
i=1?
2. Is the string you get from
xPath.evaluate("StartDate", nodes.item(i)) a valid JDBC date escape format (yyyy-mm-dd)?
3. What will happen when you convert a
Non Valid string in JDBC date escape format to a Date value?
Break each line (line 1 & line 2) into two and print the string out before converting it to a Date value.
eg.
String sStartDate = xPath.evaluate("StartDate", nodes.item(i));
System.out.println(sStartDate);
Also check this out:
The Java XPath API