O'Reilly logo

JavaServer Pages, Second Edition by Hans Bergsten

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required