mirror of https://github.com/readrops/Readrops.git
Add support for another date format
This commit is contained in:
parent
b98b8853ec
commit
b433d28177
|
@ -21,6 +21,8 @@ public final class DateUtils {
|
|||
|
||||
private static final String OFFSET_PATTERN = "Z";
|
||||
|
||||
private static final String ISO_PATTERN = ".SSSZZ";
|
||||
|
||||
/**
|
||||
* Date pattern for format : 2019-01-04T22:21:46+00:00
|
||||
*/
|
||||
|
@ -32,6 +34,7 @@ public final class DateUtils {
|
|||
.appendOptional(DateTimeFormat.forPattern(ATOM_JSON_DATE_FORMAT).getParser())
|
||||
.appendOptional(DateTimeFormat.forPattern(GMT_PATTERN).getParser())
|
||||
.appendOptional(DateTimeFormat.forPattern(OFFSET_PATTERN).getParser())
|
||||
.appendOptional(DateTimeFormat.forPattern(ISO_PATTERN).getParser())
|
||||
.toFormatter()
|
||||
.withLocale(Locale.ENGLISH)
|
||||
.withOffsetParsed();
|
||||
|
|
|
@ -41,4 +41,12 @@ public class DateUtilsTest {
|
|||
|
||||
assertEquals(0, dateTime.compareTo(DateUtils.stringToLocalDateTime("2019-01-04T22:21:46-0000")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isoPatternTest() {
|
||||
LocalDateTime dateTime = new LocalDateTime(2020, 6, 30, 11, 39, 37, 206);
|
||||
|
||||
|
||||
assertEquals(0, dateTime.compareTo(DateUtils.stringToLocalDateTime("2020-06-30T11:39:37.206-07:00")));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue