From b2a8ad458e26da29448c9bf3f0a342a1f966bfe4 Mon Sep 17 00:00:00 2001 From: aschmidt34 Date: Thu, 6 Aug 2026 13:37:45 -0500 Subject: [PATCH] Fixed issue with date-parsing error preventing the 'Water Monitoring Alert for Vets and Lab' to be sent out. --- .../wnprc_ehr/notification/WaterMonitoringNotification.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/WaterMonitoringNotification.java b/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/WaterMonitoringNotification.java index d879b4aba..f72ea013c 100644 --- a/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/WaterMonitoringNotification.java +++ b/WNPRC_EHR/src/org/labkey/wnprc_ehr/notification/WaterMonitoringNotification.java @@ -186,7 +186,11 @@ protected void findAnimalsWithEnoughWater(final Container c, final User u, final String mlsPerKg; String totalWater; for(Map mapItem : totalWaterByProject){ - LocalDateTime objectDateTime = ConvertHelper.convert(mapItem.get("date"),Date.class).toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); + // Casts date & time manually before formatting. + // Using 'toInstant()' without casting first will throw an error due to ConvertHelper.convert() returning a 'java.sql.Date' instead of the 'java.util.Date' required by toInstant(). + Date rawDate = (Date) ConvertHelper.convert(mapItem.get("date"), Date.class); + Date utilDate = new Date(rawDate.getTime()); + LocalDateTime objectDateTime = utilDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); mlsPerKg = ConvertHelper.convert(mapItem.get("mlsPerKg"),String.class) == null ? " " : ConvertHelper.convert(mapItem.get("mlsPerKg"),String.class);