Skip to content

[Bug] Default date detection rejects yyyy/MM/dd while accepting slash date-times #1154

Description

@Aias00

Fesod version

Current main at 5a9a16b.

Description

Automatic date-format detection supports slash-separated date-time strings, but a 10-character date is always assigned yyyy-MM-dd. Consequently, yyyy/MM/dd fails unless the user supplies an explicit @DateTimeFormat.

Location

fesod-sheet/src/main/java/org/apache/fesod/sheet/util/DateUtils.java:184-205

Reproduction

DateUtils.parseLocalDate("2024/01/02", null, Locale.US);
// DateTimeParseException

DateUtils.parseLocalDateTime("2024/01/02 03:04:05", null, Locale.US);
// succeeds

switchDateFormat("2024/01/02") returns yyyy-MM-dd, while the 16- and 19-character branches already select slash-specific formats.

Expected behavior

The default parser should accept yyyy/MM/dd consistently with the supported slash-separated date-time formats.

Suggested fix

Add a yyyy/MM/dd format constant, select it for 10-character strings containing /, and add Date/LocalDate converter tests.

Related existing work

#1040 concerns locale handling for java.util.Date; it does not cover delimiter detection.

Are you willing to submit a PR?

Yes.

No activity

Activity on this issue will appear here.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions