currency-formatting

Hot to get user’s regional settings for currency in JavaScript or jQuery?

萝らか妹 提交于 2019-12-10 13:54:40
问题 I’m trying to format some numbers with jQuery. I would like to get the user’s regional settings for currency and number, in order to implement the correct format (obtain the decimal separator). Is it possible to retrieve these parameters with jQuery or JavaScript? 回答1: Use toLocaleString() with style:'currency' : var amount = 123.56; alert( 'German: ' + amount.toLocaleString('de-DE',{style:'currency',currency:'EUR'}) + ', ' + 'American: ' + amount.toLocaleString('en-US',{style:'currency'

SetLocale did not work in jsp site to format currency in german

心已入冬 提交于 2019-12-09 16:53:38
问题 I'm confused with the jstl tag libs: I want to format a number to a currency with german style ... but everything I tried did not worked ... I found the following example but the output is the same -.- <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %> <html> <head> <title>format number</title> </head> <body> <c:set var="val" value="40.52" /> <p> Currency in USA

Angular 2+ Currency Mask

笑着哭i 提交于 2019-12-08 07:27:01
问题 I tried a couple of the currency masks out there for Angular 2+ but my requirements don't really fit them so I'm trying to create a Directive myself. Here's what I need: Allow for null values. Keep the value as a number, not a string. On Focus remove currency format. On blur re-format. Enter number from right to left (so for $250.00 the user would have to type [2] -> 5 -> 0. (so not starting from the decimal point) Don't allow users to type anything but numbers and decimal separator. Text

Format as currency with no trailing zeroes in wpf xaml

非 Y 不嫁゛ 提交于 2019-12-08 06:54:26
Assuming we have a viewmodel property MyMoney . How can I format it in its view xaml as a currency with no trailing zeroes? For example: MyMoney = 1; //$1 MyMoney = 1.2 //$1.2 I've tried the following in xaml (e.g. <TextBox Text="{Binding MyMoney, StringFormat=..."/> ) but it doesn't satisfy all the conditions: StringFormat=C shows currency but also trailing zeroes. StringFormat=C0 shows currency but shows only the whole number. StringFormat={}{0:0.##} does not show trailing zeroes but not as currency. StringFormat={}{0:$0.##} does not show trailing zeroes but hard-coded $ . We should be able

Format as currency with no trailing zeroes in wpf xaml

做~自己de王妃 提交于 2019-12-08 04:03:44
问题 Assuming we have a viewmodel property MyMoney . How can I format it in its view xaml as a currency with no trailing zeroes? For example: MyMoney = 1; //$1 MyMoney = 1.2 //$1.2 I've tried the following in xaml (e.g. <TextBox Text="{Binding MyMoney, StringFormat=..."/> ) but it doesn't satisfy all the conditions: StringFormat=C shows currency but also trailing zeroes. StringFormat=C0 shows currency but shows only the whole number. StringFormat={}{0:0.##} does not show trailing zeroes but not as

C# format as currency with no trailing zero decimal numbers, consider negative, and different culture

我怕爱的太早我们不能终老 提交于 2019-12-06 13:50:13
问题 How can we format a number to currency without trailing zero decimal numbers? Basically it should behave as the "C" format specifier but without trailing zeroes. Below are the test cases. value | en-US | fr-FR 1 | $1 | 1 € 1.0 | $1 | 1 € 1.1 | $1.1 | 1,1 € 1.10 | $1.1 | 1,1 € -1 | ($1) | -1 € -1.0 | ($1) | -1 € -1.1 | ($1.1) | -1,1 € 1000 | $1,000 | 1 000 € 1000.0 | $1,000 | 1 000 € Is there a way to achieve this behavior by leveraging the "C" format specifier? side note: I am continuing from

How to reposition cursor while editing EditText field which is formatted like US currency- Android

浪尽此生 提交于 2019-12-06 11:18:37
问题 I am formatting edit text field as per US currency format, where while typing number in a field, let's say "12345678" it appears like "12,345,678". For this I have used TextWatcher and on afterTextChanged(...) method I am formatting the entered text like: @Override public void afterTextChanged(Editable editable) { String str = editable.toString(); String number = str.replaceAll("[,]", ""); if (number.equals(previousNumber) || number.isEmpty()) { return; } previousNumber = number;

How to format a string as Vietnamese currency?

六月ゝ 毕业季﹏ 提交于 2019-12-06 07:33:51
问题 If I set Format in [Region and Language] to US... CultureInfo cul = CultureInfo.CurrentCulture; string decimalSep = cul.NumberFormat.CurrencyDecimalSeparator;//decimalSep ='.' string groupSep = cul.NumberFormat.CurrencyGroupSeparator;//groupSep=',' sFormat = string.Format("#{0}###", groupSep); string a = double.Parse(12345).ToString(sFormat); The result is: 12,345 (is correct) But if I set the format in [Region and Language] to VietNam, then the result is: 12345 The result should be 12.345 .

yii2 - how to set currency in main config

旧街凉风 提交于 2019-12-06 06:11:33
问题 I need to set currency format as default in config. Now when I change language in frontend the currency is changing too. How can I set it by default 回答1: In Config/main.php eg: 'component' => [ .......... 'formatter' => [ 'class' => 'yii\i18n\Formatter', 'dateFormat' => 'dd.MM.yyyy', 'decimalSeparator' => ',', 'thousandSeparator' => ' ', 'currencyCode' => 'EUR', 'nullDisplay' => '', ], 来源: https://stackoverflow.com/questions/31201293/yii2-how-to-set-currency-in-main-config

C# format as currency with no trailing zero decimal numbers, consider negative, and different culture

☆樱花仙子☆ 提交于 2019-12-04 18:31:37
How can we format a number to currency without trailing zero decimal numbers? Basically it should behave as the "C" format specifier but without trailing zeroes. Below are the test cases. value | en-US | fr-FR 1 | $1 | 1 € 1.0 | $1 | 1 € 1.1 | $1.1 | 1,1 € 1.10 | $1.1 | 1,1 € -1 | ($1) | -1 € -1.0 | ($1) | -1 € -1.1 | ($1.1) | -1,1 € 1000 | $1,000 | 1 000 € 1000.0 | $1,000 | 1 000 € Is there a way to achieve this behavior by leveraging the "C" format specifier? side note: I am continuing from this related wpf question but focusing on the formatting part and with more exhaustive test cases. I