views:

45

answers:

1

Hi, JSTL provides the fmt:formatDate tag for formatting dates. The way to use it is:

Now, in an application you do not want to specify the hardcoded format of "dd/MM/yyyy" in all your jsp's or other pages. Especially since you need to ensure that the format is configurable for the user.

One possible solution is that you specify a format for the session based on user preference and use that everywhere.

I did like to know if it is possible to specify for once a default date format for "c:out" or "fmt:formatDate" tags for a given session ?

What would be the best solution for this problem ? Should I write my own tag ?

Thanks in advance, KCN

A: 

Once the user sets the preferred format and you store it in the session scope:

<fmt:formatDate pattern="${sessionScope.myFormat}" />
Guido