java - Formatting and validating a date in JSF -


So I want to format my dateinputfield as "dd-MM-yyyy" and then confirm that the date is tomorrow Is not before.

This is the relevant code in my view:

  & lt; H: Input Text id = "Payable date" required = "true" value = "# {submitRepairBean.dueDate}" & gt; & Lt; F: convert datatype pattern = "dd-MM-yyyy" /> & Lt; F: Validator ID = "be.kdg.repaircafe.validators.DueDateValidator" /> & Lt; / H: inputText>   

This is my custom verifier:

  @FacesValidator ("be.kdg.repaircafe.validators.DueDateValidator") public class DueDateValidator implementer validator { @Override throws public valid valid (FacesContext reference, UIComponent component, object value) Validator expansion {System.out.println (value.toString ()); // For some reason this Mercury July 23 02:00 pm while inputting CET 2014 23-07-2014 date time date = new date time (value.toString ()); Detimilis long = date gates (); A demilis for a long time = 86400000; Calendar penlight = new Gregorian calendar (); // Reset hours, minutes, seconds and meet tomorrow night .set (calendar. HOUR_OF_DAY, 0); Tomorrow Midaynight.set (calendar.min, 0); Tomorrow Midsight.Sset (Calendar. SEND, 0); Yesterday Midaynight.set (Calendar. MILLISECOND, 0); Tomorrow Midaynight.add (Calendar. DAY_OF_MONTH, 1); If (Due Metis + Eked Millis & amp; nbsp; Tomorrow Subgroups .gettimeInMillis ()) {New Valuers Throw an Exception (New Face Message ("You Can not Repair Something Before Tomorrow!")); }}   

It is not understood now that it does not print in the transformed format (DD-MM-YAYA), yet I do not care unless I have the right amount Milliseconds however, the Datetime constructor throws an exception that the date is in an invalid format.

I have tried to use it with ease, with no luck.

The converter will show you the date in this format on this page (in the jsp / html page). What it does, is changing the date in the DD-MM-YY format into a string. When you pass Quali in a valid function, the format in this format does not convert to DD-MM-YY. It is a date, date is a date, so from the printing price. The string () only converts the date value into a string. Therefore, the object is a date and should work on the basis of coating only. If you want to print it in the format format in the code dd-MM-yyyy try it

  date = (date) value; SimpleDataformat SDF = New SimpleDormat ("DD-MM-Yay"); String strDate = sdf.format (date); System.out.println (strDate);    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -