A user enters his birth date in a jTextfield in the yyyy/mm/dd and I want to make sure that he enters it correctly like that and also that it is a real date. this is my code so far:
SimpleDateFormat df = new SimpleDateFormat("yyyy/mm/dd");
Date testDate = null;
Birth = jTextField3.getText();
try{
testDate = df.parse(Birth);
} catch (ParseException e){ }
if (!df.format(testDate).equals(Birth)){
JOptionPane.showMessageDialog(rootPane, "invalid date!!");
}
the error I am getting is it said I cant cast a java.sql.Date
into a java.util.Date