Name

<fmt:formatDate>

Synopsis

The <fmt:formatDate> action formats a date and time value according to locale specific rules. A custom pattern can be specified or locale-dependent default patterns for one or both of the date portion, and the time portion can be selected.

The locale is taken from the locale configuration setting or the locale from the localization context setting, or if none of these are set, determined as the best match for the user preferences (Accept-Language request header).

Syntax

<fmt:formatDate value="dateAndTime" 
  [pattern="pattern" |
    [type="time|date|both"]
    [dateStyle="default|short|medium|long|full"]
    [timeStyle="default|short|medium|long|full"]]
  [timeZone="timeZone"]
  [var="var" [scope="page|request|session|application"]] />

Attributes

Attributename

Java type

Dynamic valueaccepted

Description

value
java.util.Date

Yes

The date and time to format.

pattern
String

Yes

A custom pattern in the form accepted by java.text.SimpleDateFormat (see the next table).

type
String

Yes

Which portions to format.

dateStyle
String

Yes

One of the predefined locale-dependent date patterns.

timeStyle
String

Yes

One of the predefined locale-dependent time patterns.

timeZone

String or java.util.TimeZone

Yes

The time zone to use instead of the default.

var
String

No

The variable name. The type is String.

scope
String

No

The variable scope.

The symbols that can be used in a custom pattern, set by the pattern attribute, are the same as those supported ...

Get JavaServer Pages, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.