Skip to content

Android DateTimeFormat reports h11/h24 but formats midnight as h12/h23 #2209

Description

@mozzius

Environment

Android 15 / API 35 emulator, React Native 0.86.3, Hermes 250829098.0.17. Compared in the same app against Android Chromium WebView 124. Reproducer: https://github.com/mozzius/hermes-datetimeformat-repro (native Hermes and WebView side by side).

Minimal repro

const midnight = new Date('2026-05-28T21:54:00Z') // 00:54 in Europe/Helsinki

for (const [locale, hourCycle] of [
  ['en-GB', 'h11'],
  ['en-US', 'h24'],
]) {
  const formatter = new Intl.DateTimeFormat(locale, {
    timeStyle: 'short',
    hourCycle,
    timeZone: 'Europe/Helsinki',
  })
  console.log(locale, formatter.format(midnight), formatter.resolvedOptions().hourCycle)
}
Request Android Hermes Chromium WebView
en-GB, explicit h11 12:54 am, reports h11 00:54 am, reports h11
en-US, explicit h24 00:54, reports h24 24:54, reports h24

The day-period spacing varies by engine, but the hour at midnight is the issue: h11 must start at 0 and h24 at 24. Hermes returns the opposite cycle's hour despite reporting the requested cycle. This also affects hour12 selection: en-GB + hour12: true resolves to h11 while formatting midnight as 12:54 am; en-US + hour12: false resolves to h24 while formatting 00:54.

Source observations

  • lib/Platform/Intl/java/com/facebook/hermes/intl/DateTimeFormat.java pairs a default h23 with h11 and h12 with h24 for hour12, rather than selecting the locale's preferred 12-/24-hour cycle.
  • PlatformDateTimeFormatterICU.java maps both H11 and H12 to an h skeleton and both H23 and H24 to a k skeleton. The API 35 formatter subsequently formats 12 or 00 in the explicit midnight cases above.
  • The Android Test262 harness skips DateTimeFormat/prototype/resolvedOptions/hourCycle-timeStyle.js.

This is distinct from the Apple backend's ignored styled hour12 request in #2208. Android does honor that request and formats the Bluesky case as a 12-hour time; its incorrect midnight semantics need an Android-specific fix and regression tests. I have not tested pre-API-24 Android's separate java.text implementation.

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