summaryrefslogtreecommitdiff
path: root/src/de
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2012-06-13 21:22:50 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2012-06-13 21:22:50 +0200
commit5544035e53cb56a0ed3e93ef53dba54d381c12e4 (patch)
tree1d1feec56e4be4fc3b170893a6bbd9317124b2c6 /src/de
parent8a98d81b3e0a601916f01875b8f440768cdb26cd (diff)
downloadAntennaPod-5544035e53cb56a0ed3e93ef53dba54d381c12e4.zip
Created class for parsing RSS 2 date formats
Diffstat (limited to 'src/de')
-rw-r--r--src/de/podfetcher/syndication/namespace/rss20/NSRSS20.java2
-rw-r--r--src/de/podfetcher/syndication/util/SyndDateUtils.java40
2 files changed, 42 insertions, 0 deletions
diff --git a/src/de/podfetcher/syndication/namespace/rss20/NSRSS20.java b/src/de/podfetcher/syndication/namespace/rss20/NSRSS20.java
index 9b97c1f89..aee611db0 100644
--- a/src/de/podfetcher/syndication/namespace/rss20/NSRSS20.java
+++ b/src/de/podfetcher/syndication/namespace/rss20/NSRSS20.java
@@ -1,6 +1,7 @@
package de.podfetcher.syndication.namespace.rss20;
import java.util.ArrayList;
+import java.util.Date;
import de.podfetcher.feed.Feed;
import de.podfetcher.feed.FeedImage;
@@ -10,6 +11,7 @@ import de.podfetcher.syndication.handler.HandlerState;
import de.podfetcher.syndication.handler.SyndHandler;
import de.podfetcher.syndication.namespace.Namespace;
import de.podfetcher.syndication.namespace.SyndElement;
+import de.podfetcher.syndication.util.SyndDateUtils;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
diff --git a/src/de/podfetcher/syndication/util/SyndDateUtils.java b/src/de/podfetcher/syndication/util/SyndDateUtils.java
new file mode 100644
index 000000000..019e82b75
--- /dev/null
+++ b/src/de/podfetcher/syndication/util/SyndDateUtils.java
@@ -0,0 +1,40 @@
+package de.podfetcher.syndication.util;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import android.util.Log;
+
+/** Parses several date formats. */
+public class SyndDateUtils {
+ private static final String TAG = "DateUtils";
+ private static final String RFC822 = "dd MMM yyyy HH:mm:ss Z";
+ /** RFC 822 date format with day of the week. */
+ private static final String RFC822DAY = "EEE, " + RFC822;
+
+ public static Date parseRFC822Date(String date) {
+ Date result = null;
+ SimpleDateFormat format = new SimpleDateFormat(RFC822DAY);
+ try {
+ result = format.parse(date);
+ } catch(ParseException e) {
+ format = new SimpleDateFormat(RFC822);
+ try {
+ result = format.parse(date);
+ } catch (ParseException e1) {
+ e1.printStackTrace();
+ }
+ }
+ if (result != null) {
+ Log.d(TAG, "Day is " + result.getDay());
+ Log.d(TAG, "Hours is " + result.getHours());
+ Log.d(TAG, "Minutes is " + result.getMinutes());
+ Log.d(TAG, "Seconds is" + result.getSeconds());
+ Log.d(TAG, "Month is " + result.getMonth());
+ Log.d(TAG, "Year is " + result.getYear());
+ Log.d(TAG, format.format(result));
+ }
+ return result;
+ }
+}