diff --git a/api/src/org/labkey/api/util/DateUtil.java b/api/src/org/labkey/api/util/DateUtil.java index 09fcf056f06..38a2fa42e34 100644 --- a/api/src/org/labkey/api/util/DateUtil.java +++ b/api/src/org/labkey/api/util/DateUtil.java @@ -26,6 +26,7 @@ import org.jetbrains.annotations.Nullable; import org.junit.Assert; import org.junit.Test; +import org.labkey.api.collections.CaseInsensitiveHashSet; import org.labkey.api.data.Container; import org.labkey.api.data.ContainerManager; import org.labkey.api.pipeline.PipelineJobService; @@ -1368,6 +1369,8 @@ public static String getTimeFormatString(Container c) return FolderSettingsCache.getDefaultTimeFormat(c); } + public static final Set META_FORMATS = CaseInsensitiveHashSet.of("Date", "DateTime", "Time"); + /** * Test a date format string to determine if it matches one of LabKey's special named date formats (Date, DateTime, Time) * @param dateFormat Format string to test @@ -1375,7 +1378,7 @@ public static String getTimeFormatString(Container c) */ public static boolean isSpecialNamedFormat(String dateFormat) { - return "Date".equals(dateFormat) || "DateTime".equals(dateFormat) || "Time".equals(dateFormat); + return META_FORMATS.contains(dateFormat); } private static final FastDateFormat jsonDateFormat = FastDateFormat.getInstance(getJsonDateTimeFormatString()); diff --git a/core/src/org/labkey/core/admin/DisplayFormatAnalyzer.java b/core/src/org/labkey/core/admin/DisplayFormatAnalyzer.java index 94c9eb5fc2c..ea975298b8a 100644 --- a/core/src/org/labkey/core/admin/DisplayFormatAnalyzer.java +++ b/core/src/org/labkey/core/admin/DisplayFormatAnalyzer.java @@ -36,6 +36,7 @@ import static org.labkey.api.settings.AbstractSettingsGroup.SITE_CONFIG_USER; import static org.labkey.api.settings.LookAndFeelFolderProperties.LOOK_AND_FEEL_SET_NAME; +import static org.labkey.api.util.DateUtil.META_FORMATS; public class DisplayFormatAnalyzer { @@ -98,8 +99,6 @@ public DisplayFormatAnalyzer() .forEach(candidate -> _propertyCandidateMap.put(candidate.container(), candidate)); } - private static final Set META_FORMATS = CaseInsensitiveHashSet.of("Date", "DateTime", "Time"); - // Allows standard formats and standard meta formats private boolean isNonStandardFormat(DateDisplayFormatType type, String format) { diff --git a/experiment/src/org/labkey/experiment/api/property/DomainImpl.java b/experiment/src/org/labkey/experiment/api/property/DomainImpl.java index f50ff548aa6..5bbcecc7992 100644 --- a/experiment/src/org/labkey/experiment/api/property/DomainImpl.java +++ b/experiment/src/org/labkey/experiment/api/property/DomainImpl.java @@ -447,7 +447,7 @@ private void validatePropertyFormat(DomainProperty dp) throws ChangePropertyDesc if (!StringUtils.isEmpty(dp.getFormat())) { String ptype = dp.getRangeURI(); - if (ptype.equalsIgnoreCase(PropertyType.DATE_TIME.getTypeUri())) + if (ptype.equalsIgnoreCase(PropertyType.DATE_TIME.getTypeUri())) // TODO: Check Date and Time also? { type = " for type " + PropertyType.DATE_TIME.getXarName(); // Allow special named formats (these would otherwise fail validation)