Saturday, January 26, 2008

JSTL fineprint

The following fine print in the JSTL fmt:formatDate documentation just cost me about 45 minutes of my life:
If this action fails to determine a formatting locale, it uses java.util.Date.toString() as the output format.
Meaning that, if you do not set the locale explicitly in the JSP (with fmt:setLocale) and you e.g. use WGET against your JSP page - which per default does not carry any locale information - you get the stupid default format
Sat Jan 26 18:10:50 CET 2008
instead of whatever you specify. Even if you explicitly give a pattern with fmt:formatDate value="${now}" pattern="yyyy-MM-dd'T'HH:mm:ss'Z'"
you nevertheless get the verbose stuff from above.
You have to setLocale first...

Sick. Just sick.

No comments: