Repository navigation
HebrewDateFormatter.formatHebrewNumber: support numbers up to 999,999 (Jewish years past 9999) - #304
Merged
KosherJava merged 1 commit intoNov 6, 2026
Conversation
The thousands digit indexed a 10 letter array, so numbers over 9999 were rejected and format() threw IllegalArgumentException for every date whose Jewish year is over 9999 (Gregorian years from 6240). The thousands are now written with the same letters as other numbers (10,000 = "י׳ אלפים", 12,345 = "יב׳ שמ״ה" with long years). Output up to 9999 is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Er4Sx7LnKzzCbgDEatxkU
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The issue
HebrewDateFormatter.formatHebrewNumber(int)only accepts 0 to 9999. As a result,format()(Hebrew format) throws for every date whose Jewish year is 10,000 or more, which is any Gregorian date from the year 6240 on.The edge case
Hebrew formatting of a Jewish year of 10,000 or more.
JewishCalendaritself handles these dates fine (new JewishCalendar(LocalDate.of(6500, 1, 1)).getJewishYear()is 10,260); only the formatting fails. This is far in the future, but the date classes accept these dates and code that iterates or computes dates generically can reach them. The same limit also applies to any other caller formatting a number of 10,000 or more.What happens
The thousands are written with
jOnes[number / 1000], a 10-letter array, which is why the method rejects anything over 9999.The fix
Write the thousands with the same letters as any other number: hundreds, tens and ones, with ט״ו / ט״ז for 15 and 16, followed by the geresh. A new private
formatThousandshelper does this, and the limit moves to 999,999.י׳ אלפיםי׳ אלפיםשמ״ה(thousands dropped, as for 5786)יב׳ שמ״הOutput for every number up to 9999 is unchanged; the thousands 1 to 9 are still a single letter. The Javadoc describes the new range.
Tests
HebrewNumberAbove9999Testchecks:format()of a date in Jewish year 10,260.The new cases fail without the change.
🤖 Generated with Claude Code
https://claude.ai/code/session_015Er4Sx7LnKzzCbgDEatxkU