Search code examples
javadateformattingrssatom-feed

RFC-822 date-time format in RSS 2.0 feeds: CET not accepted?


[Updated with working solution] I have an RSS feed which gets displayed correctly in RSS clients, but when being validated by http://feedvalidator.org I get this error:

pubDate must be an RFC-822 date-time

My date is formatted as follows:

Wed, 27 Feb 2013 17:18:15 CET

Any idea what could be wrong? Could it be the timezone?

SOLUTION

Thanks to Calum I got a valid RSS feed now. Reason was the CET not being supported in the pubDate.

The following Java Code is working now fine:

String pubDate = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss Z").format(new Date());

Solution

  • The RFC indicates it only supports a very limited set of symbolic timezone names; just UTC and US ones:

     zone        =  "UT"  / "GMT"                ; Universal Time
                                                 ; North American : UT
                 /  "EST" / "EDT"                ;  Eastern:  - 5/ - 4
                 /  "CST" / "CDT"                ;  Central:  - 6/ - 5
                 /  "MST" / "MDT"                ;  Mountain: - 7/ - 6
                 /  "PST" / "PDT"                ;  Pacific:  - 8/ - 7
                 /  1ALPHA                       ; Military: Z = UT;
                                                 ;  A:-1; (J not used)
                                                 ;  M:-12; N:+1; Y:+12
                 / ( ("+" / "-") 4DIGIT )        ; Local differential
                                                 ;  hours+min. (HHMM)
    

    You probably need to specify as an offset to UTC.

    Since you say you're using Java, it looks like SimpleDateFormat will give you an RFC-822 compliant date if you use Z to format the zone in your time format (rather than z).