MySQLs standard DATO-feltformat er:ÅÅÅÅ-MM-DD
Hvorimod i Java er Dato-klassens (tilgængelig i java.util-pakken) standardformat, dow mon dd tt:mm:ss zzz yyyy
så brug denne:
Date date = txtToday.getText();
String pattern = "yyyy-MM-dd";
SimpleDateFormat formatter = new SimpleDateFormat(pattern);
String mysqlDateString = formatter.format(date);
System.out.println("Java's Default Date Format: " + date);
System.out.println("Mysql's Default Date Format: " + mysqlDateString);