Validating date java

However I have no idea how to validate the date in my method class as i am fairly new to Java. the sort iof thing I've been taught to use is Date Formmater but not sure whether this is appropriate here?if so wouldn't know how to use it Your question has attracted a lot of answers which recommend the Simple Date Format class. To give two examples, the parse() method cannot detect errornous months (i.e. “31/9/2010”, “31/09/2010” – September has 30 days only 10.

validating date java-36validating date java-8

options can be either a date string in the format of YYYY-MM-DD or a Date object.

If the form need to validate start and end date, you should take a look at the Validating fields that depend on each other or Compraing dates example.

Let’s test this with various input: 10/14/2012 = Sun Oct 14 CEST 2012 10-Jan-2012 = Tue Jan 10 CET 2012 = Fri Mar 01 CET 2002 12/03/2010 = Fri Dec 03 CET 2010 19.

Feb.2011 = Sat Feb 19 CET 2011 4/20/2012 = Fri Apr 20 CEST 2012 some string = null 123456 = null null = null Thus you can quickly check weather given string is a valid Date or not using Date Util class.

Server side validation is performed by a web server, after input has been sent to the server.