Wednesday, 15 May 2013

validation - Validating a date in java -


I am using Netbeans IDE 7.2. I have two different classes, newDateTest.java and newDateMethod.java , I currently use one of my method classes to validate a date from a user input I have been used in my test class.

So far in my test class I have the following:

  try {prompt = "Please enter a date in format dd-mm-yyyy"; Println (expedited); String inputdate = in.next (); IsValid = newDateMethod.validDate (input, input, input); If (isValid) {System.out.println ("valid date"); } And {System.out.println ("INVALID DATE"); }} Hold (ArrayedAxOutBoundApensionAb) {System.out.println (oob); }}  

Although I do not know how to validate date in my method class because I am quite new in Java

Can any solution come in? The way I am taught to use is the date format but it is not sure whether it is appropriate here or not? If this does not happen then how to use it

like this:

 < Code> Date Dates = Nil; String inputdate = "07-01-2013"; Try {dateFormat formatter = new SimpleDateFormat ("dd-MM-yyyy"); Formatter.setLenient (wrong); Date = formater PRSE (InputDate); } Hold (ParseException e) {e.printStackTrace (); }  

No comments:

Post a Comment