mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
generate default date when no date is found while parsing entry
This commit is contained in:
@@ -2,6 +2,7 @@ package com.commafeed.backend.feeds;
|
|||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@@ -48,8 +49,7 @@ public class FeedParser {
|
|||||||
entry.setTitle(handleContent(item.getTitle()));
|
entry.setTitle(handleContent(item.getTitle()));
|
||||||
entry.setContent(handleContent(getContent(item)));
|
entry.setContent(handleContent(getContent(item)));
|
||||||
entry.setUrl(item.getLink());
|
entry.setUrl(item.getLink());
|
||||||
entry.setUpdated(item.getUpdatedDate() != null ? item
|
entry.setUpdated(getUpdateDate(item));
|
||||||
.getUpdatedDate() : item.getPublishedDate());
|
|
||||||
|
|
||||||
feed.getEntries().add(entry);
|
feed.getEntries().add(entry);
|
||||||
}
|
}
|
||||||
@@ -61,6 +61,17 @@ public class FeedParser {
|
|||||||
return feed;
|
return feed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Date getUpdateDate(SyndEntry item) {
|
||||||
|
Date date = item.getUpdatedDate();
|
||||||
|
if (date == null) {
|
||||||
|
date = item.getPublishedDate();
|
||||||
|
}
|
||||||
|
if (date == null) {
|
||||||
|
date = new Date();
|
||||||
|
}
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private String getContent(SyndEntry item) {
|
private String getContent(SyndEntry item) {
|
||||||
String content = null;
|
String content = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user