Skip to content

Bugfix: Use Locale.ROOT for ISO8601 date formatting to prevent localized digits#126

Merged
marcprux merged 1 commit into
skiptools:mainfrom
fhasse95:ISO8601-Format-Locale-Bugfix
Jul 17, 2026
Merged

Bugfix: Use Locale.ROOT for ISO8601 date formatting to prevent localized digits#126
marcprux merged 1 commit into
skiptools:mainfrom
fhasse95:ISO8601-Format-Locale-Bugfix

Conversation

@fhasse95

Copy link
Copy Markdown
Contributor

This PR fixes a bug where Date.ISO8601Format() would produce localized ISO 8601 strings depending on the user's Android device locale instead of a stable, locale-independent representation.

The root of the issue was that the previous implementation used Java's default locale (java.util.Locale.getDefault()). On devices set to languages like Arabic or Hindi, however, SimpleDateFormat automatically localized the output:

  • It converted numbers to non-ASCII digits (e.g., ٢٠٢٦ instead of 2026)
  • It shifted years based on alternative calendars

Example:

iOS:
iOS (AR)

Android:
Android (AR)

As you can see here, the digits of the date string were converted to Eastern Arabic numerals before the bugfix, whereas on iOS the ISO 8601 representation remained the same in every locale.

Since I use these date strings as timestamps in SkipSQL, this localization broke my database layer and caused record deserialization to fail as soon as the system language was changed.

To fix the issue, I replaced java.util.Locale.getDefault() with java.util.Locale.ROOT. Similar to Swift's en_US_POSIX, it avoids locale-specific number systems and ensures the output uses standard ASCII digits (0–9), making the ISO 8601 representation consistent across Android and iOS regardless of the user's device locale.


Thank you for contributing to the Skip project! Please use this space to describe your change and add any labels (bug, enhancement, documentation, etc.) to help categorize your contribution.

Please review the contribution guide at https://skip.dev/docs/contributing/ for advice and guidance on making high-quality PRs.

Skip Pull Request Checklist:

  • REQUIRED: I have signed the Contributor Agreement
  • REQUIRED: I have tested my change locally with swift test
  • OPTIONAL: I have tested my change on an iOS simulator or device
  • OPTIONAL: I have tested my change on an Android emulator or device

  • AI was used to generate or assist with generating this PR. Please specify below how you used AI to help you, and what steps you have taken to manually verify the changes.

@cla-bot cla-bot Bot added the cla-signed label Jul 16, 2026
@marcprux

Copy link
Copy Markdown
Member

Great fix, thanks!

@marcprux
marcprux merged commit 4310e97 into skiptools:main Jul 17, 2026
2 checks passed
@fhasse95
fhasse95 deleted the ISO8601-Format-Locale-Bugfix branch July 17, 2026 05:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants