diff --git a/app/src/main/java/com/readrops/app/utils/DateUtils.java b/app/src/main/java/com/readrops/app/utils/DateUtils.java index 04a5f967..f7ea1e36 100644 --- a/app/src/main/java/com/readrops/app/utils/DateUtils.java +++ b/app/src/main/java/com/readrops/app/utils/DateUtils.java @@ -15,7 +15,7 @@ public final class DateUtils { * Fri, 04 Jan 2019 22:21:46 GMT * Fri, 04 Jan 2019 22:21:46 +0000 */ - private static final String RSS_2_BASE_PATTERN = "EEE, dd MMM yyyy HH:mm:ss "; + private static final String RSS_2_BASE_PATTERN = "EEE, dd MMM yyyy HH:mm:ss"; private static final String GMT_PATTERN = "ZZZ"; @@ -32,7 +32,8 @@ public final class DateUtils { public static LocalDateTime stringToLocalDateTime(String value) { DateTimeFormatter formatter = new DateTimeFormatterBuilder() - .appendOptional(DateTimeFormat.forPattern(RSS_2_BASE_PATTERN).getParser()) + .appendOptional(DateTimeFormat.forPattern(RSS_2_BASE_PATTERN + " ").getParser()) // with timezone + .appendOptional(DateTimeFormat.forPattern(RSS_2_BASE_PATTERN).getParser()) // no timezone, important order here .appendOptional(DateTimeFormat.forPattern(ATOM_JSON_DATE_FORMAT).getParser()) .appendOptional(DateTimeFormat.forPattern(GMT_PATTERN).getParser()) .appendOptional(DateTimeFormat.forPattern(OFFSET_PATTERN).getParser()) diff --git a/app/src/test/java/com/readrops/app/DateUtilsTest.java b/app/src/test/java/com/readrops/app/DateUtilsTest.java index 732346d0..95b9058f 100644 --- a/app/src/test/java/com/readrops/app/DateUtilsTest.java +++ b/app/src/test/java/com/readrops/app/DateUtilsTest.java @@ -23,6 +23,13 @@ public class DateUtilsTest { assertEquals(0, dateTime.compareTo(DateUtils.stringToLocalDateTime("Fri, 04 Jan 2019 22:21:46 +0000"))); } + @Test + public void rssDate3Test() { + LocalDateTime dateTime = new LocalDateTime(2019, 1, 4, 22, 21, 46); + + assertEquals(0, dateTime.compareTo(DateUtils.stringToLocalDateTime("Fri, 04 Jan 2019 22:21:46"))); + } + @Test public void atomJsonDateTest() { LocalDateTime dateTime = new LocalDateTime(2019, 1, 4, 22, 21, 46);