Class 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 Details

  • Method Details

    • useAM_PM

      public void useAM_PM(boolean useAM_PM)
    • allowSpaceBeforeAM_PM

      public void allowSpaceBeforeAM_PM(boolean allow)
    • validate

      public boolean validate(FormData fd, jakarta.servlet.http.HttpServletRequest req)
      Works with any field that returns a String via it's
      invalid reference
      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
      Throws:
      ClassCastException - If the field's
      invalid reference
      Field#getValue
      method does not return a String