Monday, November 03, 2008

just about the nerdiest thing I could come up with this morning

ISO 8601 is an international standard for representing date and time information.

RFC 3339 is a subset of ISO 8601 intended for use in Internet protocols. (Note that since this dates only from 2002, you won't see it used in either SMTP or HTTP headers, the only two Internet protocols that most people are likely to ever see)

Meanwhile, XML Schema defines a dateTime that is also based of ISO 8601. These are used, of course, in XML documents. This is what you get when you serialize a java.util.Date field with JAXB, for instance.

Now here's the fun part: RFC 3339 and xsd:dateTime, although both based on ISO 8601 and looking at first glance very similar, are not identical. And apparently different enough that it gave the Atom developers some pause, as seen here.

Read all of this shit. There's a lesson to learn somewhere.

As an example of where this can sow confusion, assume you're developing a web service (possibly a RESTful one) that needs to pass date and time information in places that are protocol headers nor part of XML documents. For instance, date fields embedded in the URL. It makes sense to use something based on ISO 8601, and it also makes sense to use one of the two subsets mentioned here. But which one?

Comments: