From 62996f21950aa3a4e505204b12fd9f2cdc1b4d78 Mon Sep 17 00:00:00 2001 From: Nick Van Date: Fri, 18 Oct 2024 08:33:22 -0500 Subject: [PATCH] Remove TimeConverter logger Remove TimeConverter warning logs when failing to parse dateTimeString. Update 'toZonedDateTime(dateTimeString)' to return early for performance if dateTimeString is null or empty. --- .../java/mil/army/usace/hec/vortex/io/TimeConverter.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/vortex-api/src/main/java/mil/army/usace/hec/vortex/io/TimeConverter.java b/vortex-api/src/main/java/mil/army/usace/hec/vortex/io/TimeConverter.java index 9ac0ee2e..bebab0ef 100644 --- a/vortex-api/src/main/java/mil/army/usace/hec/vortex/io/TimeConverter.java +++ b/vortex-api/src/main/java/mil/army/usace/hec/vortex/io/TimeConverter.java @@ -12,10 +12,8 @@ import java.time.temporal.ChronoField; import java.time.temporal.TemporalAccessor; import java.util.Locale; -import java.util.logging.Logger; class TimeConverter { - private static final Logger logger = Logger.getLogger(TimeConverter.class.getName()); private static final ZoneId UTC = ZoneId.of("UTC"); private static final DateTimeFormatter ymdFormatter = new DateTimeFormatterBuilder() @@ -52,6 +50,10 @@ static ZonedDateTime toZonedDateTime(CalendarDate calendarDate) { } static ZonedDateTime toZonedDateTime(String dateTimeString) { + if (dateTimeString == null || dateTimeString.isEmpty()) { + return null; + } + TemporalAccessor parsedDate = parseDate(dateTimeString); if (parsedDate instanceof ZonedDateTime zonedDateTime) { @@ -61,8 +63,6 @@ static ZonedDateTime toZonedDateTime(String dateTimeString) { } else if (parsedDate instanceof LocalDate localDate) { return localDate.atStartOfDay(UTC); } else { - String message = String.format("Unable to parse: %s", dateTimeString); - logger.warning(message); return null; } }