-
Notifications
You must be signed in to change notification settings - Fork 651
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: signDisplay plus sign behaviour fixed for NumberFormat (#1483)
Summary: Fixes following issue: - #1466 - #1138 - #789 **Why this change is made?** There are few cases where signDisplay is not being handled correctly. Examples: ``` 1. new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR', signDisplay: 'exceptZero', }).format(8537.71) Output: +8,537,71+ Expected: +8.537,71 € 2. new Intl.NumberFormat('ja-JP', { style: 'currency', currency: 'JPY', signDisplay: 'exceptZero' }).format(123456.789) Output: +123,457 Expected: +¥123,457 ``` **ChangeLog** This PR updates the implementation and testing of the signDisplay functionality in the DecimalFormat class within the Hermes engine, specifically for Android API level 31 and above. **Key Changes:** Implementation: - Integrated the **setSignAlwaysShown** method of DecimalFormat for API level 31 and above to control the display of the sign (+ or -) based on the signDisplay option. [For more detail about setSignAlwaysShown check [here](https://developer.android.com/reference/android/icu/text/DecimalFormat#setSignAlwaysShown(boolean))] - For API levels below 31, maintained the existing logic for handling sign display, ensuring backward compatibility. Pull Request resolved: #1483 Test Plan: - Added a comprehensive set of test cases in **HermesIntlAndroidTest.java** to validate the behaviour of the signDisplay functionality, specifically for API level 31 and above. - Test cases cover scenarios for signDisplay: `NEVER | ALWAYS | EXCEPTZERO` Reviewed By: avp Differential Revision: D62153166 Pulled By: neildhar fbshipit-source-id: d45c55ae7ffbfbc38ec4b331339859b8c96486c7
- Loading branch information
1 parent
2ca5da2
commit a75e14a
Showing
6 changed files
with
103 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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