Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/src/org/labkey/api/data/DataColumn.java
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,8 @@ else if (_inputType.equalsIgnoreCase("checkbox"))
private void renderSelectFormInput(HtmlWriter out, String formFieldName, Object value, List<String> strValues, boolean disabledInput, NamedObjectList entryList)
{
boolean isMultiple = "select.multiple".equalsIgnoreCase(_inputType);
if (isMultiple && !formFieldName.startsWith(MultiChoice.ARRAY_MARKER))
formFieldName = MultiChoice.ARRAY_MARKER + formFieldName;
SelectBuilder select = new SelectBuilder()
.disabled(disabledInput)
.multiple(isMultiple)
Expand Down
13 changes: 11 additions & 2 deletions api/src/org/labkey/api/util/SubstitutionFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,17 @@ public Object format(Object value)
return defaultTimeFormat.format(value);
else if (value instanceof java.sql.Date)
return date.format(value);
else if (value instanceof Date)
return defaultDateTimeFormat.format(value).replace('T', ' '); // replace T with whitespace for human readability
else if (value instanceof Date dateVal)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix seems like good behavior. Is there also a change we can make to ColumnInfo.getConvert() or getJavaClass() to convert to the more specific type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PropertyType.Date.convert already does DateUtil.getDateOnly, if that's what you mean?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at this a little, I have a PR that changes that method to return java.sql.Date instead of java.util.Date also PropertyType.DATE_TIME convert to return java.util.Timestamp. Haven't run through tests though.

{
// both date and datetime column type are of type Date, format based on time portion of the date value
LocalDateTime ldt = LocalDateTime.ofInstant(dateVal.toInstant(), ZoneId.systemDefault());
boolean isDateOnly = ldt.toLocalTime().equals(java.time.LocalTime.MIDNIGHT);

if (isDateOnly)
return date.format(value);
else
return defaultDateTimeFormat.format(value).replace('T', ' '); // replace T with whitespace for human readability
}

return value;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.labkey.query.sql;

import org.apache.commons.beanutils.ConversionException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.labkey.api.data.AbstractTableInfo;
Expand Down Expand Up @@ -371,6 +372,11 @@ private QExpr getBoundExpression(Map<FieldKey, ColumnInfo> columnMap)
return _boundExpr;
}

@Override
public Object convert(Object o) throws ConversionException
{
return o;
}

/*
* TESTS
Expand Down