Skip to content

NamedInstantPatternTest#compatibilityOfLegacyPattern fails in timezones with minute offsets (e.g., GMT+05:30) #3885

@ramanathan1504

Description

@ramanathan1504

Description

The compatibilityOfLegacyPattern test in NamedInstantPatternTest fails when the build is run in an environment with a timezone that has a non-zero minute offset, such as India Standard Time (GMT+05:30).

The test asserts that a legacy date formatter and a new formatter produce identical output. For the ISO8601_OFFSET_DATE_TIME_HH enum value, the legacy formatter produces a timezone offset with minutes (e.g., +0530), while the new formatter produces an offset with only hours (e.g., +05), causing the assertion to fail.

This was discovered while working on PR #3874.

Configuration

  • Version: 2.26.0-SNAPSHOT
  • Operating system: [macOS 26]
  • JDK: [OpenJDK 17.0.5]
  • Timezone: GMT+05:30 (e.g., Asia/Kolkata)

Logs

[INFO] Running org.apache.logging.log4j.core.pattern.NamedInstantPatternTest
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.123 s <<< FAILURE! - in org.apache.logging.log4j.core.pattern.NamedInstantPatternTest
[ERROR] compatibilityOfLegacyPattern(org.apache.logging.log4j.core.pattern.NamedInstantPattern)  Time elapsed: 0.1 s  <<< FAILURE!
org.opentest4j.AssertionFailedError:
[Compatibility failed for pattern: 'ISO8601_OFFSET_DATE_TIME_HH']
expected: "2025-08-17T12:10:08,887+0530"
 but was: "2025-08-17T12:10:08,887+05"
        at org.apache.logging.log4j.core.pattern.NamedInstantPatternTest.compatibilityOfLegacyPattern(NamedInstantPatternTest.java:45)

Reproduction

  1. Set the local machine's system timezone to one with a 30 or 45-minute offset. For example, Asia/Kolkata (India Standard Time, GMT+05:30).
  2. Check out the main branch of the logging-log4j2 repository.
  3. Run the build with mvn clean install.
  4. Observe the build failure in the log4j-core-test module, originating from NamedInstantPatternTest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect, unexpected, or unintended behavior of existing codelayoutsAffects one or more Layout pluginswaiting-for-maintainer

    Type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions