Android: I can't figure out SimpleDateFormat-Collection of common programming errors
I get an unhandled type parse exception error on formatter.parse(str)
For that, you’ll need to explicitly handle the exception, either by declaring that the currently executing method just throws it, or by catching it. For more information, I highly recommend going through the Exceptions Lesson in the Java Tutorial.
Here’s an example of catching the exception.
String str = "26/08/1994";
SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy"); //please notice the capital M
Date date;
try
{
date = formatter.parse(str);
}
catch (ParseException e)
{
// Handle error condition.
}