So, this is because SyndFeedImpl uses the same field for the date and publishedDate fields (from the DC module):
@Override public Date getPublishedDate() { return getDCModule().getDate(); } @Override public void setPublishedDate(final Date publishedDate) { getDCModule().setDate(publishedDate); }
Since RSS093Generator (used by RSS20Generator ) creates the pubDate element from the specified element, but also inherits from DCModuleGenerator, you get both of these:
final Date pubDate = item.getPubDate(); if (pubDate != null) { eItem.addContent(generateSimpleElement("pubDate", DateParser.formatRFC822(pubDate, Locale.US))); }
and this:
final Date dcDate = dcModule.getDate(); if (dcDate != null) { for (final Date date : dcModule.getDates()) { element.addContent(generateSimpleElement("date", DateParser.formatW3CDateTime(date, Locale.US))); } }
This interaction can be prevented by implementing your own SyndFeed your own. In this case, all you have to do is create a class variable to hold your pubDate so that DCModule never sets the date and therefore never generates your unwanted dc:date element.
I ran into the same problem and solved it using this SyndFeed implementation:
public class CustomSyndFeed extends SyndFeedImpl { protected Date publishedDate; @Override public Date getPublishedDate() { return publishedDate; } @Override public void setPublishedDate(final Date publishedDate) { this.publishedDate = new Date(publishedDate.getTime()); } }
source share