File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
main/java/org/apache/xmpbox
test/java/org/apache/xmpbox Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,14 @@ public static Calendar toCalendar(String date) throws IOException
9393
9494 if (Pattern .matches ("^\\ d{4}-\\ d{2}-\\ d{2}T.*" , date ))
9595 {
96- return fromISO8601 (date );
96+ try
97+ {
98+ return fromISO8601 (date );
99+ }
100+ catch (DateTimeParseException ex )
101+ {
102+ throw new IOException (ex );
103+ }
97104 }
98105 if (date .startsWith ("D:" ))
99106 {
Original file line number Diff line number Diff line change @@ -109,7 +109,13 @@ void testDateConversion() throws IOException
109109 convDate = DateConverter .toCalendar ("2025-09-03T15:43:47.989082+00:00" );
110110 assertEquals (989 , convDate .get (Calendar .MILLISECOND ));
111111
112+ // test some bad strings
112113 assertThrows (IOException .class , () -> DateConverter .toCalendar ("123" ));
114+ assertThrows (IOException .class , () -> DateConverter .toCalendar ("2008-12-31T19:48:30+19:00" ));
115+ assertThrows (IOException .class , () -> DateConverter .toCalendar ("2008-12-31T19:48:30-19:00" ));
116+ assertThrows (IOException .class , () -> DateConverter .toCalendar ("2008-12-02T21:04:0Z" ));
117+ assertThrows (IOException .class , () -> DateConverter .toCalendar ("0-01-01T00:00:00Z" ));
118+ assertThrows (IOException .class , () -> DateConverter .toCalendar ("2009-03-16T01:15:19-0-4:00" ));
113119
114120 // Test missing seconds
115121 assertEquals (DateConverter .toCalendar ("2015-12-08T12:07:00-05:00" ),
You can’t perform that action at this time.
0 commit comments