2222package org .apache .xmpbox ;
2323
2424import java .io .IOException ;
25- import java .text .ParseException ;
26- import java .text .SimpleDateFormat ;
2725import java .time .LocalDateTime ;
2826import java .time .ZoneId ;
2927import java .time .ZonedDateTime ;
3028import java .time .format .DateTimeFormatter ;
3129import java .time .format .DateTimeFormatterBuilder ;
3230import java .time .format .DateTimeParseException ;
3331import java .util .Calendar ;
34- import java .util .Date ;
3532import java .util .GregorianCalendar ;
3633import java .util .Locale ;
3734import java .util .SimpleTimeZone ;
@@ -58,19 +55,6 @@ public final class DateConverter
5855 .append (DateTimeFormatter .ISO_LOCAL_DATE_TIME ).parseLenient ().appendOffset ("+HH:MM" , "Z" ).parseStrict ()
5956 .toFormatter ();
6057
61- // The Date format is supposed to be the PDF_DATE_FORMAT, but not all PDF
62- // documents
63- // will use that date, so I have added a couple other potential formats
64- // to try if the original one does not work.
65- private static final SimpleDateFormat [] POTENTIAL_FORMATS = {
66- new SimpleDateFormat ("EEEE, dd MMM yyyy hh:mm:ss a" ),
67- new SimpleDateFormat ("EEEE, MMM dd, yyyy hh:mm:ss a" ),
68- new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ss'Z'" ),
69- new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ssz" ),
70- new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ss" ),
71- new SimpleDateFormat ("yyyy-MM-dd'T'HH:mm:ss.S" )
72- };
73-
7458 /**
7559 * According to check-style, Utility classes should not have a public or default constructor.
7660 */
@@ -202,32 +186,7 @@ public static Calendar toCalendar(String date) throws IOException
202186 }
203187 catch (NumberFormatException e )
204188 {
205-
206- // remove the arbitrary : in the timezone. SimpleDateFormat can't handle it
207- if (date .charAt (date .length () - 3 ) == ':' &&
208- (date .charAt (date .length () - 6 ) == '+' || date .charAt (date .length () - 6 ) == '-' ))
209- {
210- // that's a timezone string, remove the :
211- date = date .substring (0 , date .length () - 3 ) + date .substring (date .length () - 2 );
212- }
213- for (int i = 0 ; (retval == null ) && (i < POTENTIAL_FORMATS .length ); i ++)
214- {
215- try
216- {
217- Date utilDate = POTENTIAL_FORMATS [i ].parse (date );
218- retval = new GregorianCalendar ();
219- retval .setTime (utilDate );
220- }
221- catch (ParseException pe )
222- {
223- // ignore and move to next potential format
224- }
225- }
226- if (retval == null )
227- {
228- // we didn't find a valid date format so throw an exception
229- throw new IOException ("Error converting date:" + date , e );
230- }
189+ throw new IOException ("Error converting date:" + date , e );
231190 }
232191 }
233192 return retval ;
0 commit comments