getDisplayValue Business Rule
The Expand XSLT of the predefined Date Field Type includes a GetValue behavior. It is defined as follows:
<GetValue>
<date>
<getValue>Date-year</getValue>
-
<getValue>Date-month</getValue>
-
<getValue>Date-day</getValue>
</date>
</GetValue>
When no getDisplayValue behavior is defined for this Field then the result of this GetValue Behavior is used as the display value.
Because GetValue returns a Java Date object, the summary page of the WebForm would then show a string such as 'Thu Oct 27 00:00:00 CEST 2005'. This string not only shows the day, month and year but also the hours, minutes and seconds. Clearly, this is not desired, since the date field only consists of the day, month and year.
To avoid the hours, minutes and seconds being shown, define a GetDisplayValue Behavior as follows:
<GetDisplayValue>
<ifThen>
<isNotEmpty>
<getValue>
<literal>Date</literal>
</getValue>
</isNotEmpty>
<formatDate>
<getValue/>
<literal>dd-MM-yyyy</literal>
</formatDate>
</ifThen>
</GetDisplayValue>
Wherever the display value of a Date field must be rendered, include this Behavior for WebForms to invoke. The Behavior first checks if a date value is entered in this field and, if so, it invokes the formatDate Business Rule in order to obtain a string representation of the date that is of the form dd-MM-yyyy where dd denotes the day, MM denotes the month and yyyy denotes the year. This representation then serves as the display value of this field. Now, the summary page will show a string without the hours, minutes and seconds, such as "27-10-2005". Of course, you can modify the second element in the formatDate element to use a different date format instead.