1616package org .labkey .test .tests .external .labModules ;
1717
1818import org .apache .commons .lang3 .StringUtils ;
19+ import org .apache .commons .lang3 .time .DateFormatUtils ;
20+ import org .apache .commons .lang3 .time .DateUtils ;
1921import org .apache .commons .lang3 .tuple .Pair ;
2022import org .apache .poi .ss .usermodel .Sheet ;
2123import org .apache .poi .ss .usermodel .Workbook ;
2224import org .junit .Assert ;
2325import org .junit .Test ;
2426import org .junit .experimental .categories .Category ;
27+ import org .labkey .api .util .DateUtil ;
2528import org .labkey .remoteapi .CommandException ;
2629import org .labkey .remoteapi .Connection ;
2730import org .labkey .remoteapi .collections .CaseInsensitiveHashMap ;
@@ -301,6 +304,9 @@ private void dateParseTest() throws ParseException
301304 String dateFormat3 = "MM/dd/yy" ;
302305 checkDate ("02/20/11" , dateFormat3 );
303306 checkDate ("3/5/99" , dateFormat3 );
307+
308+ String clientFormattedString = (String )executeScript ("return Ext4.Date.format(LDK.ConvertUtils.parseDate('2024-01-01', 'c'), 'Y-m-d');" );
309+ assertEquals ("Incorrect date parsing" , clientFormattedString , "2024-01-01" );
304310 }
305311
306312 private void checkDate (String dateStr , String javaFormatStr ) throws ParseException
@@ -1415,6 +1421,7 @@ private void samplesTableTest() throws Exception
14151421 columnLabels .add (getColumnLabel (srr , name ));
14161422 }
14171423
1424+ SimpleDateFormat dateFormat = new SimpleDateFormat ("yyyy-MM-dd" );
14181425 List <List <String >> rows = new ArrayList <>();
14191426 for (Map <String , Object > row : srr .getRows ())
14201427 {
@@ -1425,7 +1432,7 @@ private void samplesTableTest() throws Exception
14251432 String val = row .get (name ) == null ? "" : String .valueOf (row .get (name ));
14261433 if (name .toLowerCase ().contains ("date" ))
14271434 {
1428- val = StringUtils .isEmpty (val ) ? "" : ExcelHelper . getDateTimeFormat (). format (new Date (val ));
1435+ val = StringUtils .isEmpty (val ) ? "" : dateFormat . format (Date . parse (val ));
14291436 }
14301437
14311438 target .add (val );
@@ -1440,10 +1447,10 @@ private void samplesTableTest() throws Exception
14401447 List <List <String >> lines = ExcelHelper .getFirstNRows (sheet , 5 );
14411448
14421449 Assert .assertEquals (columnLabels , lines .get (0 ));
1443- Assert .assertEquals (rows .get (0 ), lines .get (1 ));
1444- Assert .assertEquals (rows .get (0 ), lines .get (2 ));
1445- Assert .assertEquals (rows .get (1 ), lines .get (3 ));
1446- Assert .assertEquals (rows .get (1 ), lines .get (4 ));
1450+ Assert .assertEquals ("Row did not match. ExcelHelper pattern: " + ExcelHelper . getDateTimeFormat (). toPattern (), rows .get (0 ), lines .get (1 ));
1451+ Assert .assertEquals ("Row did not match. ExcelHelper pattern: " + ExcelHelper . getDateTimeFormat (). toPattern (), rows .get (0 ), lines .get (2 ));
1452+ Assert .assertEquals ("Row did not match. ExcelHelper pattern: " + ExcelHelper . getDateTimeFormat (). toPattern (), rows .get (1 ), lines .get (3 ));
1453+ Assert .assertEquals ("Row did not match. ExcelHelper pattern: " + ExcelHelper . getDateTimeFormat (). toPattern (), rows .get (1 ), lines .get (4 ));
14471454 }
14481455
14491456 refresh ();
0 commit comments