Skip to content

[Enhancement] Extract format-string date detection out of DateUtils #1062

Description

@nkuprins

Search before asking

  • I searched in the issues and found nothing similar.

Motivation

DateUtils mixes date parsing/formatting with format-string date detection. To improve readability and reduce complexity, I suggest refactoring it to follow SRP.

Solution

Extract format detection into ExcelDateFormatDetector(package-private). Move isADateFormat, isADateFormatUncached, isInternalDateFormat, and their regex/cache internals into a new class.

DateUtils keeps the same three public methods, now one-line delegations - no API change, no behaviour change.

Example:

public static boolean isADateFormat(Short formatIndex, String formatString) {
      return ExcelDateFormatDetector.isADateFormat(formatIndex, formatString);
}
public static void removeThreadLocalCache() {
      DATE_FORMAT_THREAD_LOCAL.remove();
      DATE_TIME_FORMATTER_THREAD_LOCAL.remove();
      ExcelDateFormatDetector.removeThreadLocalCache();
}

Alternatives

No response

Anything else?

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions