File tree 2 files changed +25
-4
lines changed
main/java/fr/free/nrw/commons/utils
test/kotlin/fr/free/nrw/commons/utils
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() {
25
25
* Gets the timestamp pattern for a date
26
26
* @return timestamp
27
27
*/
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 ;
32
33
}
33
34
}
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