Class VTime

  extended by fc.web.forms.FieldValidator
      extended by fc.web.forms.VTime

public final class VTime
extends FieldValidator

Validates a time entered in a text box. Typical examples may look like: 1:23 pm, 1 am, 1:00 am, and 01:23 pm (with or without "am/pm" as part of the entered text). By default, all of the above patterns are allowed and the space between the time and "am/pm" is optional. This can be changed via the useAM_PM and allowSpaceBeforeAM_PM(boolean) methods.

Constructor Summary
VTime(AbstractText field, String errorMessage)
Method Summary
 void allowSpaceBeforeAM_PM(boolean allow)
 void useAM_PM(boolean useAM_PM)
 boolean validate(FormData fd, javax.servlet.http.HttpServletRequest req)
          Works with any field that returns a String via it's Field#getValue method.
Methods inherited from class fc.web.forms.FieldValidator
getErrorMessage, getField
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public VTime(AbstractText field,
             String errorMessage)
Method Detail


public void useAM_PM(boolean useAM_PM)


public void allowSpaceBeforeAM_PM(boolean allow)


public boolean validate(FormData fd,
                        javax.servlet.http.HttpServletRequest req)
Works with any field that returns a String via it's Field#getValue method.

If validation succeeds, this method puts the parsed date in the specified form data as the validated value for the target field. This saves the hassle of reparsing the text when (typically) retrieving it later to save the value out to the database.

Specified by:
validate in class FieldValidator
ClassCastException - If the field's Field#getValue method does not return a String