Java code for validating date

*/ public class Multi Format Date Validation { /** * @param args */ public static void main(String[] args) { println("Starting Data Validation Check"); /* Below Test Case is format and validity test.

* 2012 was a leap year and hence 29 is a valid date. */ is Date Valid("02/29/2012 "); } /* * Core Function for validation check.

* So, for this implementation, we prepare an array that contains the formats against which we will * perform validation test.

* Next, we loop the entire array and test against each format.

* */ public static boolean is Date Valid(String date Value) { boolean return Val = false; /* * Set the permissible formats.

* A better approach here would be to define all formats in a .properties file * and load the file during execution.

Catch parse exception to test if validation failed. Loop the above process for the set of formats against which the validation needs to be performed.

* If the validation fails, test for other formats till array iteration is completed.

* If it passes for a given format, break the loop and exit.


  1. Pingback:

  2. eric   •  

    This one for all the girls out there, who didn’t mind being treated like a kid by their guy.

  3. eric   •  

    International marriage agency to meet single Russian and Ukrainian women who are looking in different parts of the world for a good man for marriage.

  4. eric   •  

    A UNIQUE online friendship and dating agency has been created for adults with a learning disability across the north of England.

  5. eric   •  

    About CBS Television Stations Group (Formerly Paramount Stations Group), a division of CBS Inc., officially entered the Atlanta market September 1, 1995, acquiring WVEU-TV from BCG Communications, which held the license since sign-on in 1981.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>