currency

Format currency without currency symbol

↘锁芯ラ 提交于 2019-11-27 03:48:33
I am using NumberFormat.getCurrencyInstance(myLocale) to get a custom currency format for a locale given by me. However, this always includes the currency symbol which I don't want, I just want the proper currency number format for my given locale without the currency symbol. Doing a format.setCurrencySymbol(null) throws an exception.. The following works. It's a bit ugly, but it fulfils the contract: NumberFormat nf = NumberFormat.getCurrencyInstance(); DecimalFormatSymbols decimalFormatSymbols = ((DecimalFormat) nf).getDecimalFormatSymbols(); decimalFormatSymbols.setCurrencySymbol(""); (

What is the standard for formatting currency values in JSON?

只愿长相守 提交于 2019-11-27 03:45:04
问题 Bearing in mind various quirks of the data types, and localization, what is the best way for a web service to communicate monetary values to and from applications? Is there a standard somewhere? My first thought was to simply use the number type. For example "amount": 1234.56 I have seen many arguments about issues with a lack of precision and rounding errors when using floating point data types for monetary calculations--however, we are just transmitting the value, not calculating, so that

How do I add a new Currency to java.util.Currency for an existing country code in Java 7?

£可爱£侵袭症+ 提交于 2019-11-27 03:24:53
问题 For example, the Chinese currency has the ISO 4217 code CNY . Since free global trading in that currency is restricted though, there's a second 'offshore' currency equivalent, called CNH . Wikipedia has a bit of summary of this all. In Java 7 , there's a method for updating the set of three letter ISO 4217 codes that the JVM ships with. However, it can't be used to add a separate currency code to an existing country code: it would replace CNY with CNH , which is no good for my purposes. How

How do I convert from a money datatype in SQL server?

雨燕双飞 提交于 2019-11-27 03:09:01
问题 I have a money data type in SQL Server. How do I reformat 0.00 to 0 in my query? 回答1: Normal money conversions will preserve individual pennies: SELECT convert(varchar(30), moneyfield, 1) The last parameter decides what the output format looks like: 0 (default) No commas every three digits to the left of the decimal point, and two digits to the right of the decimal point; for example, 4235.98. 1 Commas every three digits to the left of the decimal point, and two digits to the right of the

Need API for currency converting [closed]

偶尔善良 提交于 2019-11-27 03:04:28
Please advice API for currency converting which returns JSON or small size html. I use http://www.google.com/finance/converter?a=1&from=RUB&to=USD that returns HTML of 11 kb. I use it in my iOS app. Thanks in advance! free.currencyconverterapi.com returns results in JSON format. The web service also supports JSONP. The API is very easy to use, and it lets you convert one currency to another. Disclaimer, I'm the author of the website. A sample conversion URL is: http://free.currencyconverterapi.com/api/v6/convert?q=USD_PHP&compact=ultra&apiKey=sample-api-key which will return a value in json

What to do with Java BigDecimal performance?

家住魔仙堡 提交于 2019-11-27 02:53:51
I write currency trading applications for living, so I have to work with monetary values (it's a shame that Java still doesn't have decimal float type and has nothing to support arbitrary-precision monetary calculations). "Use BigDecimal!" — you might say. I do. But now I have some code where performance is an issue, and BigDecimal is more than 1000 times (!) slower than double primitives. The calculations are very simple: what the system does is calculating a = (1/b) * c many many times (where a , b and c are fixed-point values). The problem, however, lies with this (1/b) . I can't use fixed

How can I format numbers as currency string in JavaScript?

可紊 提交于 2019-11-27 02:13:56
I would like to format a price in JavaScript. I'd like a function which takes a float as an argument and returns a string formatted like this: "$ 2,500.00" What's the best way to do this? haykam Number.prototype.toFixed This solution is compatible with every single major browser: const profits = 2489.8237; profits.toFixed(3) //returns 2489.824 (rounds up) profits.toFixed(2) //returns 2489.82 profits.toFixed(7) //returns 2489.8237000 (pads the decimals) All you need is to add the currency symbol (e.g. "$" + profits.toFixed(2) ) and you will have your amount in dollars. Custom function If you

Get the currency from current culture?

放肆的年华 提交于 2019-11-27 01:44:01
问题 Is there a way to get current information dynamically from the apps culture settings? Basically if the user has set the culture to US I want to know the currency is dollars, or if they have it set to UK I want to pound sterling etc... etc.. This is so I can send this information to PayPal when a payment is being made 回答1: Use the RegionInfo.ISOCurrencySymbol property. For example: var ri = new RegionInfo(System.Threading.Thread.CurrentThread.CurrentUICulture.LCID); Console.WriteLine(ri

How to get currency exchange rates in R

六月ゝ 毕业季﹏ 提交于 2019-11-27 01:41:05
问题 Are there are any R packages/functions to get exchange rates in real time, e.g. from Google Finance? Would prefer to avoid RCurl or other parsers if something's already out there. Specifically, given vectors of "from" and "to" currency symbols, I'd like to know the rates. Something like: IdealFunction(c("CAD", "JPY", "USD"), c("USD", "USD", "EUR")) 回答1: You can use quantmod to get yahoo quotes. (I'm not sure how delayed yahoo FX quotes are, or how often they're updated.) library(quantmod)

Not getting currency symbols for specific Locale

房东的猫 提交于 2019-11-27 00:45:07
问题 I am trying to get the symbols of the currencies based on their Locale. But instead of returning a symbol, it is returning the code. I have a snippet: import java.util.Currency; import java.util.Locale; public class CurrencyFormat { public void displayCurrencySymbols() { Currency currency = Currency.getInstance(Locale.US); System.out.println("United States: " + currency.getSymbol()); } public static void main(String[] args) { new CurrencyFormat().displayCurrencySymbols(); } } For Locale.US it