If you use a JFormattedTextField in Swing to accept user entered dates, you may be annoyed by the default behavior of correcting dates. If the user enters “March 36th”, it will automatically “fix” it to read “April 5th”. Clever little text field! You deserve a pat on the head for figuring that out, now DON’T EVER DO THAT AGAIN!. I saw this question asked on Javaranch.com and the solution is posted there. I was searching around for a way to do this with the JFormattedTextField, but it turns out you have to set the behavior of the DateFormat object to not lenient:
DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM);
df.setLenient(false);
final JFormattedTextField text = new JFormattedTextField(df);