Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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());
like image 391
basZero Avatar asked Mar 06 '13 12:03

basZero


2 Answers

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).

like image 157
Calum Avatar answered Nov 20 '22 16:11

Calum


You have to use the Z to format the time zone as Calum said, but don't forget to specify the Locale too or else it won't work if the computer is not in English...

Here is my working code :

new SimpleDateFormat("E, d MMM yyyy HH:mm:ss Z", Locale.US).format(new Date());
like image 24
Fredszaq Avatar answered Nov 20 '22 16:11

Fredszaq