users@glassfish.java.net

JSTL formatDate and W3C HTML5 Validator bug

From: <glassfish_at_javadesktop.org>
Date: Sat, 18 Sep 2010 23:06:22 PDT

I am using the default glassfish 3.0.1 install and libraries. I was trying out some new HTML5 stuff, and wanted to validate it. However, it seems like the JSTL formatDate is formatting the date very differently than what I want it to, and this seems to happen only for the W3C validation service.

I made a new project just to make sure that this wasn't some bug in my own application. The following JSP demonstrates this (deployed to http://page.doesntexist.com/test/html5time.jsp ):

[code]
<!DOCTYPE html>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<jsp:useBean id="now" class="java.util.Date" />
<html><head><title>JSTL HTML5 Time Test</title></head>
    <body>The time is now
        <time datetime="<fmt:formatDate value="${now}" pattern="yyyy-MM-dd'T'HH:mm:ss'Z'"/>">
            <fmt:formatDate value="${now}" pattern="h:mm a z 'on' EEEE, MMMM d, yyyy" />.
        </time>
</body></html>
[/code]
In Firefox, IE, Chrome, and Opera, the <time> element is rendered as:

[code]
        <time datetime="2010-09-19T01:34:13Z">
            1:34 AM EDT on Sunday, September 19, 2010.
        </time>
[/code]
which is perfect HTML5! However, when I enter the URL into the W3C validator, it sees:

[code]
        <time datetime="Sun Sep 19 01:24:18 EDT 2010">
            Sun Sep 19 01:24:18 EDT 2010.
        </time>
[/code]
which is both not expected, nor is it proper HTML5, and the page fails validation.

I have intercepted packets with Wireshark, and this is not a bug with the validator, as the incorrect data is being sent from the server. I can copy and paste what Firefox gets into the validator, and it passes.
[Message sent by forum member 'abailey']

http://forums.java.net/jive/thread.jspa?messageID=483079