I have a List of String values that contains the date in the format "yyyy-MM-dd".
I am currently trying to iterate through the list to add the individual values to the DB.
How do I convert the individual String values in the String List to java.sql.Date values in order for them to match the data type contained in the database?
Below is an example of the code I am using:
List<String> accessedDate = usageEvent.getDate();
List<Integer> totlUsageHits = usageEvent.getHits();
List<Integer> totlUsageVisitors = usageEvent.getVisitors();
Iterator<String> accessDate = accessedDate.iterator();
Iterator<Integer> hits = totlUsageHits.iterator();
Iterator<Integer> visitors = totlUsageVisitors.iterator();
while (accessDate.hasNext() && hits.hasNext() && visitors.hasNext()) {
insert.setDate(1, accessDate.next());
insert.setInt(2, hits.next());
insert.setInt(3, visitors.next());
insert.addBatch();
}
Where I have insert.setDate(1, accessDate.next());, I want to change the String values from this list to java.sql.Date values.
Any help would be appreciated!