In any IDE (Integrated Development Environment), editor show the compile type error that will be unresolved at compile-time.
What you are observing the behavior of IDE in your case, at sdf.parse(d);
means it can throw an parse exception at runtime, So you have to handle it accordinly. Otherwise program will be crashed.
In second code snippet of yours, It will catch an parse exception when occured and show you the exception e.printStackTrace();
for your record and code will not crash, i.e. exit(0)
or exit(1)
with error, more
While in last code snippet of yours, method is been decleared that it may throw an exception, So if it called from any other source, this should be handled, say try catch.
You can use any of the two solution, its just your choice.
more
following is the method signature in SimpleDateFormat
public Date parse(String source) throws ParseException
So this throws indicates that when this method is been called this must be handled