String from = "2019.03.03";
SimpleDateFormat fDate = new SimpleDateFormat("yyyy.MM.dd");
Date n = fDate.parse(from);
It has unhandled exception type ParseException "fDate.parse
(from)" this line
How can I fix this code
String from = "2019.03.03";
SimpleDateFormat fDate = new SimpleDateFormat("yyyy.MM.dd");
Date n = fDate.parse(from);
It has unhandled exception type ParseException "fDate.parse
(from)" this line
How can I fix this code
The error says we need to handle "if" a parse exception is thrown. To handle exception, we can use try-catch block, like this:
try {
String from = "2019.03.03";
SimpleDateFormat fDate = new SimpleDateFormat("yyyy.MM.dd");
Date n = fDate.parse(from);
System.out.println(n);
} catch(ParseException ex) {
ex.printStackTrace();
}