string-format: String.format/formatted/printf cheat sheet module (specifier anatomy, rounding vs C printf, locales, Indian lakh/crore grouping Formatter cannot do, format exceptions, %t dates, concat cost), 11 contract tests
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b7Sr2zcoRD2watXv1G
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
== what the JDK gives for 123456789 ==
|
||||
String.format(en_IN, "%,d") : 123,456,789
|
||||
String.format(hi_IN, "%,d") : 123,456,789
|
||||
NumberFormat.getInstance(en_IN) : 123,456,789
|
||||
NumberFormat currency (en_IN) : ₹123,456,789.50
|
||||
CLDR pattern for en_IN : #,##0.###
|
||||
|
||||
== a DecimalFormat pattern that LOOKS like it should work ==
|
||||
pattern #,##,##0 -> grouping size : 3
|
||||
pattern #,##,##0 -> output : 123,456,789
|
||||
|
||||
== compact formatting knows crore but drops the digits ==
|
||||
compact (default rounding) : 12Cr
|
||||
compact (2 fraction digits) : 12.35Cr
|
||||
|
||||
== IndianNumberFormat ==
|
||||
0 -> 0
|
||||
999 -> 999
|
||||
1,000 -> 1,000
|
||||
12,345 -> 12,345
|
||||
123,456 -> 1,23,456
|
||||
1,234,567 -> 12,34,567
|
||||
123,456,789 -> 12,34,56,789
|
||||
-123,456,789 -> -12,34,56,789
|
||||
12,34,567.89
|
||||
-1,00,000.00
|
||||
Rs. 12,34,567.50
|
||||
|
||||
== plugging it into a format string through %s ==
|
||||
Balance 9,87,65,432.10
|
||||
Reference in New Issue
Block a user