numberformatter

PHP NumberFormatter and Currency, can't set precision

瘦欲@ 提交于 2019-12-04 16:24:11
问题 I want to set a precision of 0 when using the NumberFormatter PHP class (from Intl extension) with currency. However I've got some strange result. Here: $numberFormatter = new NumberFormatter('en-US', NumberFormatter::CURRENCY); $numberFormatter->setAttribute(NumberFormatter::FRACTION_DIGITS, 0); echo $numberFormatter->formatCurrency('45', 'USD'); It outputs $45 , which is what I want. However, if I change the currency to EUR with the same settings: echo $numberFormatter->formatCurrency('45',

NumberFormatter::SPELLOUT spellout-ordinal in russian and italian

六月ゝ 毕业季﹏ 提交于 2019-12-03 13:06:04
this code works for english, spanish and german ordninal numbers, but with russian or italian ordninal numbers it doesn't work. 'ru-RU' , 'it-IT' also don't work I get for example in russian for 2 -> два (this is the cardinal number) , but I want the ordinal number and this would be here 2 -> второй. I get for example in italian for 2 -> due (this is the cardinal number) , but I want the ordinal number and this would be here 2 -> secondo. Update: I found a solution with works in french, spain, german and some other languages: maskuline ordinal numbers: %spellout-ordinal-maskuline feminine

how to use persian numbers in UItextField in swift 3?

匆匆过客 提交于 2019-12-02 09:32:58
Hi I am using text field in my swift3 application - I want when user enter a number in the text field instead of english number textfield shows persian numbers - my textfield keyboard has set to just enter number so the user can't use text inside the text field with keyboard so here is my codes that doesn't work override func viewDidLoad() { super.viewDidLoad() let numberFormatter = NumberFormatter() numberFormatter.locale = Locale(identifier: "fa") numberFormatter.numberStyle = NumberFormatter.Style.decimal let cm:Int? = Int(englishNumber.text!) if cm != nil { numberFormatter.string(from:

Preserve trailing zeroes using NumberFormatter in PHP

百般思念 提交于 2019-12-01 13:24:14
I'm working on upgrading a legacy system from PEAR's i18nv2 class to PHP's built-in INTL library. When I specify a pattern like #,##0.## and run NumberFormatter::format() on a number like 12345.1000 I get 12,345.1 shouldn't trailing zeroes be preserved? Is there a good way to add trailing zeroes after the fact taking into consideration that in many locales, a decimal is represented by a comma instead of the decimal character? Explained with code: $n = new NumberFormatter('en_CA', NumberFormatter::PATTERN_DECIMAL, '#,##0.##'); echo $n->format(12345.10000); http://icu-project.org/apiref/icu4c

java.lang.NumberFormatException: For input string: “20,475.00”

♀尐吖头ヾ 提交于 2019-12-01 06:41:24
i am trying to get the running balance of my system. To do it, i get the sum of all numbers in the jtable from column AMOUNT and subtract the sum to the value inside the txtLoanAmount. here's my code snippet: String LoanAmount = txtLoanAmount.getText(); float f = Float.valueOf(LoanAmount.trim()).floatValue(); float balance = 0; float sum = 0; for(int i=0;i<=tableLedger.getRowCount()-1;i++) { sum = sum + Float.parseFloat(tableLedger.getModel().getValueAt(i, 2).toString()); } balance = f - sum; System.out.println(balance); now i get the error message : Exception in thread "AWT-EventQueue-0" java

java.lang.NumberFormatException: For input string: “20,475.00”

南笙酒味 提交于 2019-12-01 05:24:11
问题 i am trying to get the running balance of my system. To do it, i get the sum of all numbers in the jtable from column AMOUNT and subtract the sum to the value inside the txtLoanAmount. here's my code snippet: String LoanAmount = txtLoanAmount.getText(); float f = Float.valueOf(LoanAmount.trim()).floatValue(); float balance = 0; float sum = 0; for(int i=0;i<=tableLedger.getRowCount()-1;i++) { sum = sum + Float.parseFloat(tableLedger.getModel().getValueAt(i, 2).toString()); } balance = f - sum;

Class 'NumberFormatter' not found error in simple PHP program

蓝咒 提交于 2019-11-30 05:48:32
问题 I have a simple PHP program but I am encountering this error: Class 'NumberFormatter' not found I have researched similar issues in Stackoverflow but honestly none gave a concrete solution. Others suggest to upgrade the version of PHP, others un-comment a specific line in the php.ini file and none of those worked for me. Below is my code: I even used the suggested solution from https://bugs.php.net but it still doesn't work. <!DOCTYPE html> <html> <body> <?php function writeMsg(){ $f = new