Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/gitlab4j/api/utils/ISO8601.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class ISO8601 {
public static final String UTC_PATTERN = "yyyy-MM-dd HH:mm:ss 'UTC'";

private static final DateTimeFormatter ODT_WITH_MSEC_PARSER = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd[['T'][ ]HH:mm:ss.SSS[ ][XXXXX][XXXX]]").toFormatter();
private static final DateTimeFormatter ODT_PARSER = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd[['T'][ ]HH:mm:ss[.SSS][ ][X][XXX]]")
private static final DateTimeFormatter ODT_PARSER = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd[['T'][ ]HH:mm:ss[.SSS][ ][XXX][X]]")
.parseDefaulting(ChronoField.HOUR_OF_DAY, 0)
.parseDefaulting(ChronoField.MINUTE_OF_HOUR, 0)
.parseDefaulting(ChronoField.SECOND_OF_MINUTE, 0)
Expand Down
13 changes: 11 additions & 2 deletions src/test/java/org/gitlab4j/api/TestISO8601.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ public class TestISO8601 {
private static final String SPACEY_GITLAB_DATE_WITH_MSEC = "2018-03-12 10:16:46.123 +0700";
private static final String ISO8601_GITLAB_DATE_WITH_MSEC ="2018-03-12T10:16:46.123+0700";

private static final String ISO8601_DATE_OFFSET_COLON = "2018-03-12T10:16:46+07:00";

private static final String ISO8601_DATE_MSEC = "2018-03-12T10:16:46.123Z";
private static final String ISO8601_DATE_OFFSET_COLON = "2018-03-12T10:16:46.123+00:00";
private static final String ISO8601_DATE_MSEC_OFFSET_COLON = "2018-03-12T10:16:46.123+00:00";
private static final String ISO8601_GITLAB_DATE_MSEC = "2018-03-12T03:16:46.123-0700";
private static final String SPACEY_GITLAB_UTC_DATE_MSEC = "2018-03-12 10:16:46.123 UTC";

Expand Down Expand Up @@ -69,8 +71,15 @@ public void testMsecDateParse() throws ParseException {

@Test
public void testOffsetColonDateParse() throws ParseException {
Date gitlabOffsetDate = ISO8601.toDate(ISO8601_DATE_OFFSET_COLON);
Date gitlabDate = ISO8601.toDate(ISO8601_GITLAB_DATE);
assertEquals(gitlabDate, gitlabOffsetDate);
}

@Test
public void testOffsetColonMsecDateParse() throws ParseException {
Date msecDate = ISO8601.toDate(ISO8601_DATE_MSEC);
Date gitlabMsecDate = ISO8601.toDate(ISO8601_DATE_OFFSET_COLON);
Date gitlabMsecDate = ISO8601.toDate(ISO8601_DATE_MSEC_OFFSET_COLON);
assertEquals(msecDate, gitlabMsecDate);
}
}