Conversion date and time from a string in Java

try {
    String stringDate = "1945-05-09";
    DateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
    Date victoryDate = format.parse(stringDate);
catch (ParseException e) {
    e.printStackTrace();
}