File tree Expand file tree Collapse file tree 2 files changed +25
-4
lines changed
main/java/fr/free/nrw/commons/utils
test/kotlin/fr/free/nrw/commons/utils Expand file tree Collapse file tree 2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -25,9 +25,10 @@ public static SimpleDateFormat getIso8601DateFormatShort() {
2525 * Gets the timestamp pattern for a date
2626 * @return timestamp
2727 */
28- public static SimpleDateFormat getIso8601DateFormatTimestamp () {
29- SimpleDateFormat simpleDateFormat = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss" , Locale .ROOT );
30- simpleDateFormat .setTimeZone (TimeZone .getTimeZone ("UTC" ));
31- return simpleDateFormat ;
28+ public static SimpleDateFormat getIso8601DateFormatTimestamp () {
29+ final SimpleDateFormat simpleDateFormat = new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ssX" ,
30+ Locale .ROOT );
31+ simpleDateFormat .setTimeZone (TimeZone .getTimeZone ("UTC" ));
32+ return simpleDateFormat ;
3233 }
3334}
Original file line number Diff line number Diff line change 1+ package fr.free.nrw.commons.utils
2+
3+ import org.hamcrest.core.IsEqual.equalTo
4+ import org.junit.Assert.assertThat
5+ import org.junit.Test
6+
7+ class CommonsDateUtilTest {
8+
9+ @Test
10+ fun `Iso8601DateFormatTimestamp parses legal date` () {
11+ val iso8601DateFormatTimestamp = CommonsDateUtil
12+ .getIso8601DateFormatTimestamp()
13+ val parsedDate = iso8601DateFormatTimestamp
14+ .parse(" 2020-04-07T14:21:57Z" )
15+ assertThat(
16+ " 2020-04-07T14:21:57Z" ,
17+ equalTo(iso8601DateFormatTimestamp.format(parsedDate))
18+ )
19+ }
20+ }
You can’t perform that action at this time.
0 commit comments