Why you're getting the error:
How to Fix it:
Surround the offending code with try catch
- it's like saying, I will capture the error, log it and hopefully be able to do something about it.
try { // add this line
System.out.print("\n\n\tEnter START Date in mm/dd/yyyy format: ");
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
Date lowDate = sdf.parse(stdin.nextLine());
System.out.print("\n\n\tEnter END Date in mm/dd/yyyy format: ");
Date highDate = sdf.parse(stdin.nextLine());
for(int i = 0; i < list.size(); i++)
{
int dateSpot = list.get(i).indexOf(" ");
String currentDate = list.get(i);
currentDate.substring(0, dateSpot);
Date newCurrentDate = sdf.parse(currentDate);
if (newCurrentDate.compareTo(lowDate) >= 0 && newCurrentDate.compareTo(highDate) <= 0)
{
System.out.println("\n\t" + list.get(i));
}
}
} catch (ParseException ex) {
ex.printStackTrace(); // or log it using a logging framework
}
or throw it at the main - here, it's like saying: whoever it is that's calling this method, please take care of this problem if it happens:
public static void main (String[] args) throws Exception