Package org.apache.guacamole.form
Class DateField
- java.lang.Object
-
- org.apache.guacamole.form.Field
-
- org.apache.guacamole.form.DateField
-
public class DateField extends Field
Represents a date field. The field may contain only date values which conform to a standard pattern, defined by DateField.FORMAT.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.guacamole.form.Field
Field.Type
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
format(Date date)
Converts the given date into a string which follows the format used by date fields.static Date
parse(String dateString)
Parses the given string into a corresponding date.-
Methods inherited from class org.apache.guacamole.form.Field
getName, getOptions, getType, setName, setOptions, setType
-
-
-
-
Field Detail
-
FORMAT
public static final String FORMAT
The date format used by date fields, compatible with SimpleDateFormat.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DateField
public DateField(String name)
Creates a new DateField with the given name.- Parameters:
name
- The unique name to associate with this field.
-
-
Method Detail
-
format
public static String format(Date date)
Converts the given date into a string which follows the format used by date fields.- Parameters:
date
- The date value to format, which may be null.- Returns:
- The formatted date, or null if the provided time was null.
-
parse
public static Date parse(String dateString) throws ParseException
Parses the given string into a corresponding date. The string must follow the standard format used by date fields, as defined by FORMAT and as would be produced by format().- Parameters:
dateString
- The date string to parse, which may be null.- Returns:
- The date corresponding to the given date string, or null if the provided date string was null or blank.
- Throws:
ParseException
- If the given date string does not conform to the standard format used by date fields.
-
-