Skip to content

Commit 500d5b7

Browse files
committed
Fixed related to converter util refactoring
1 parent 9f6cca0 commit 500d5b7

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

api/src/org/labkey/api/util/SubstitutionFormat.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,17 @@ public Object format(Object value)
8282
return defaultTimeFormat.format(value);
8383
else if (value instanceof java.sql.Date)
8484
return date.format(value);
85-
else if (value instanceof Date)
86-
return defaultDateTimeFormat.format(value).replace('T', ' '); // replace T with whitespace for human readability
85+
else if (value instanceof Date dateVal)
86+
{
87+
// both date and datetime column type are of type Date, format based on time portion of the date value
88+
LocalDateTime ldt = LocalDateTime.ofInstant(dateVal.toInstant(), ZoneId.systemDefault());
89+
boolean isDateOnly = ldt.toLocalTime().equals(java.time.LocalTime.MIDNIGHT);
90+
91+
if (isDateOnly)
92+
return date.format(value);
93+
else
94+
return defaultDateTimeFormat.format(value).replace('T', ' '); // replace T with whitespace for human readability
95+
}
8796

8897
return value;
8998
}

query/src/org/labkey/query/sql/CalculatedExpressionColumn.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.labkey.query.sql;
22

3+
import org.apache.commons.beanutils.ConversionException;
34
import org.jetbrains.annotations.NotNull;
45
import org.jetbrains.annotations.Nullable;
56
import org.labkey.api.data.AbstractTableInfo;
@@ -371,6 +372,11 @@ private QExpr getBoundExpression(Map<FieldKey, ColumnInfo> columnMap)
371372
return _boundExpr;
372373
}
373374

375+
@Override
376+
public Object convert(Object o) throws ConversionException
377+
{
378+
return o;
379+
}
374380

375381
/*
376382
* TESTS

0 commit comments

Comments
 (0)