@@ -28,6 +28,8 @@ Licensed to the Apache Software Foundation (ASF) under one or more
2828import java .net .MalformedURLException ;
2929import java .net .URL ;
3030import java .nio .file .Path ;
31+ import java .text .DateFormat ;
32+ import java .text .SimpleDateFormat ;
3133import java .util .ArrayList ;
3234import java .util .Date ;
3335import java .util .List ;
@@ -62,19 +64,27 @@ private NotInstantiable() {
6264 }
6365
6466 private static Stream <Arguments > createValueTestParameters () {
65- // forse the PatternOptionBuilder to load / modify the TypeHandler table.
67+ // force the PatternOptionBuilder to load / modify the TypeHandler table.
6668 final Class <?> ignore = PatternOptionBuilder .FILES_VALUE ;
6769 // reset the type handler table.
6870 TypeHandler .resetConverters ();
6971 final List <Arguments > lst = new ArrayList <>();
7072
73+ /*
74+ * Dates calculated from strings are dependent upon configuration and environment settings for the
75+ * machine on which the test is running. To avoid this problem, convert the time into a string
76+ * and then unparse that using the converter. This produces strings that always match the correct
77+ * time zone.
78+ */
79+ final Date date = new Date (1023400137000L );
80+ final DateFormat dateFormat = new SimpleDateFormat ("EEE MMM dd HH:mm:ss zzz yyyy" );
81+
7182 try {
7283 lst .add (Arguments .of (Instantiable .class .getName (), PatternOptionBuilder .CLASS_VALUE , Instantiable .class ));
7384 lst .add (Arguments .of ("what ever" , PatternOptionBuilder .CLASS_VALUE , ParseException .class ));
7485
7586 lst .add (Arguments .of ("what ever" , PatternOptionBuilder .DATE_VALUE , ParseException .class ));
76- lst .add (Arguments .of ("Thu Jun 06 17:48:57 EDT 2002" , PatternOptionBuilder .DATE_VALUE ,
77- new Date (1023400137000L )));
87+ lst .add (Arguments .of (dateFormat .format (date ), PatternOptionBuilder .DATE_VALUE , date ));
7888 lst .add (Arguments .of ("Jun 06 17:48:57 EDT 2002" , PatternOptionBuilder .DATE_VALUE , ParseException .class ));
7989
8090 lst .add (Arguments .of ("non-existing.file" , PatternOptionBuilder .EXISTING_FILE_VALUE , ParseException .class ));
0 commit comments