<fmt:formatDate ?>

Here is a sample JSP code

<h4>US</h4>

<fmt:setLocale value="us_US"/>

<fmt:formatDate value="${now}" pattern="yyyyMMdd"/>

<h4>RU</h4>

<fmt:setLocale value="ru_RU"/>

<fmt:formatDate value="${now}" pattern="yyyyMMdd"/>

And on the output I got:

US

Fri Jan 19 14:38:21 MSK 2007

RU

20070119

I expected to see two identical rows but why they are not? Doesn't the "pattern" attribute rules the output format? If not how does one can manipulate with the format?

[740 byte] By [knightinminda] at [2007-11-26 15:36:39]
# 1

The problem is caused because "us_US" is not a valid locale.

Try "en_US" for the desired effect, or even just "en"

<fmt:setLocale value="junkValue"/>

<fmt:formatDate value="${now}" pattern="yyyyMMdd"/>

Output: Fri Jan 19 14:38:21 MSK 2007

It seems when the locale is not set correctly, the formatDate tag cannot use the pattern.

evnafetsa at 2007-7-8 21:54:22 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thanx!
knightinminda at 2007-7-8 21:54:23 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...