Skip to content

Commit

Permalink
Remove TimeConverter logger
Browse files Browse the repository at this point in the history
Remove TimeConverter warning logs when failing to parse dateTimeString. Update 'toZonedDateTime(dateTimeString)' to return early for performance if dateTimeString is null or empty.
  • Loading branch information
Nick Van authored and nickvan612 committed Oct 18, 2024
1 parent 840b020 commit 62996f2
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
}
Expand Down

0 comments on commit 62996f2

Please sign in to comment.