Parses and formats dates.





Specifies a desired date format supported by the Java class java.text.SimpleDateFormat.


Optional, specifies the maximum date allowed for input. The format of this setting must conform to the format specified by the date attribute.


Optional, specifies the minimum date allowed for input. The format of this setting must conform to the format specified by the date attribute.

Usage Notes

You can specify how dates are formatted in a form with the date tag converter. The date converter uses the formatting and parsing methods and formats of the java.text.SimpleDateFormat class. For example:

This date converter:

Renders output like this:

date="MMM d, yyyy"

November 12, 1998



See the JDK documentation on java.text.SimpleDateFormat for details on how the converter parses strings into Dates and formats Dates into strings for display.

Because the date converter does not flag an error if a two-digit value is entered when a four-digit value is expected for the year, your form validation logic might require error checking to handle this case. Also, if the field expects a two-digit year entry, the year is interpreted as being no more than 80 years before or 20 years after the current date.

The following example uses the date converter to format a date:

<dsp:input bean="NewUser.lastActivityDate" date="MMMM d, yyyy"/>

The following example defines a parameter as a Date:

<dsp:param name="lastActivityDate" value="3/4/98" date="M/dd/yy"/>

If a form contains a date input field, you might want to place a note near that field that indicates the expected format. If a date is entered in the wrong format, it is interpreted according to the format specified in the date converter, and as a result might store an incorrect date.


You can use the date converter’s optional mindate and maxdate attributes individually or together to restrict the range of dates a field accepts. For example, if you have a field for the user’s birth date, you typically want to require that the user enter a four-digit year to make sure the date the customer enters is unambiguous, as in this tag:

<dsp:input bean="NewUser.birthDate" date="M/dd/yyyy"/>

If users enter a two-digit year instead, the date might be interpreted differently than expected. For example, 2/16/59 is interpreted as February 16, 0059. By using the mindate attribute, however, you can reject dates that are earlier than a certain date you specify. For example, the following tag includes a mindate (in the format specified by the date attribute) of January 1, 1900:

<dsp:input bean="Employee1.birthDate" date="M/dd/yyyy" mindate="01/01/1900"/>

In this case, if the user enters 2/16/59, the entry is rejected, because February 16, 0059 is earlier than the date specified by mindate.

When a user enters a date that is outside of the bounds specified by mindate and maxdate, the converter rejects the value and throws a TagConversionException with an invalidDate error code. You can include error handling in your form to display a message instructing the user to enter a valid date.

Copyright © 1997, 2012 Oracle and/or its affiliates. All rights reserved. Legal Notices