currency

If you have the ISO country code `US`, `FR`, how do you get the Locale code (`Locale.US`, `Locale.FRANCE`)?

£可爱£侵袭症+ 提交于 2019-12-19 05:14:30
问题 If you have the country code US , FR (ISO-3166-1 alpha-2 country code), how do you get the Locale code ( Locale.US , Locale.FRANCE ) to do something like this: System.out.println(DecimalFormat.getCurrencyInstance(Locale.US).format(12.34)); System.out.println(DecimalFormat.getCurrencyInstance(Locale.FRANCE).format(12.34)); $12.34 12,34 € 回答1: You can't, because a Locale is used to hold a language, not a country. It can hold a language for a specific country, and for a specific variant in this

c# Decimal to string for currency

走远了吗. 提交于 2019-12-19 05:07:06
问题 To display a currency we do: ToString("0.##") For value 5.00 the output is: 5 For value 5.98 the output is: 5.98 For value 5.90 the output is: 5.9 I need the third case to come out with 2 decimal points, eg: 5.90 How can I do this without it affecting the other results? 回答1: I know this doesn't give you a format that fixes the problem, but it's a simple solution to work around it. (5.00).ToString("0.00").Replace(".00",""); // returns 5 (5.90).ToString("0.00").Replace(".00", ""); // returns 5

Money data on PostgreSQL using Java

拟墨画扇 提交于 2019-12-18 19:08:35
问题 I'm writing a Java program that mines currency exchange data. The data can have multiple digits in the decimal such as "0.973047". After some research I was able to find out BigDecimal is the right data type for Java, but which data type should I be using for PostgreSQL? 回答1: NUMERIC / DECIMAL As Joachim Isaksson said, you want to use NUMERIC/DECIMAL type, as an arbitrary precision type. Two important points about NUMERIC / DECIMAL : Read the doc carefully to learn that you should specify the

How can get ' USDJPY'(currency rates) with pandas and yahoo finance?

浪尽此生 提交于 2019-12-18 16:48:43
问题 I am learning and using the pandas and python. Today, I am trying to make a fx rate table, but I got a trouble with getting the pricess of 'USDJPY'. When I get a prices of 'EUR/USD', i code like this. eur = web.DataReader('EURUSD=X','yahoo')['Adj Close'] it works. But when I wrote jpy = web.DataReader('USDJPY=X','yahoo')['Adj Close'] the error message comes like this: --------------------------------------------------------------------------- IOError Traceback (most recent call last) in () --

How to get specific culture currency pattern

久未见 提交于 2019-12-18 14:11:04
问题 How do i get the currency pattern for a specific culture? For Example: Instead of using: string.Format("{0:c}", 345.10) I want to use this: string.Format("#.##0,00 €;-#.##0,00 €", 345.10); But how do i get the pattern string (like "#.##0,00 €;-#.##0,00 €") for each culture my application needs? I cant use the "{0:c}" pattern because if the user switches the language the currency should be the same. 回答1: A CultureInfo contains a NumberFormatInfo and this class describes (among other things)

How to get specific culture currency pattern

我的未来我决定 提交于 2019-12-18 14:10:32
问题 How do i get the currency pattern for a specific culture? For Example: Instead of using: string.Format("{0:c}", 345.10) I want to use this: string.Format("#.##0,00 €;-#.##0,00 €", 345.10); But how do i get the pattern string (like "#.##0,00 €;-#.##0,00 €") for each culture my application needs? I cant use the "{0:c}" pattern because if the user switches the language the currency should be the same. 回答1: A CultureInfo contains a NumberFormatInfo and this class describes (among other things)

How to get specific culture currency pattern

社会主义新天地 提交于 2019-12-18 14:10:05
问题 How do i get the currency pattern for a specific culture? For Example: Instead of using: string.Format("{0:c}", 345.10) I want to use this: string.Format("#.##0,00 €;-#.##0,00 €", 345.10); But how do i get the pattern string (like "#.##0,00 €;-#.##0,00 €") for each culture my application needs? I cant use the "{0:c}" pattern because if the user switches the language the currency should be the same. 回答1: A CultureInfo contains a NumberFormatInfo and this class describes (among other things)

Setting currency with form select with Money gem

…衆ロ難τιáo~ 提交于 2019-12-18 12:38:28
问题 I have been working quite a few hours on this one but I can't figure out this one. I am willing to have the user select a corresponding currency for the price he is filling in the form. I am using the Money Gem (https://github.com/RubyMoney/money ). All values are set correctly BUT not the currency that only sets to its default value (USD) whatever is sent through the form. I suppose this is my lack of experience with the Money gem. In My Model: require 'money' composed_of :price_per_unit,

What is the python for Java's BigDecimal?

烂漫一生 提交于 2019-12-18 11:50:30
问题 In Java, when we program money it is recommended to use the class BigDecimal for money. Is there something similar in python? I would like something object-oriented that can have a currency and an exchange rate, has that been done? I store money as integers of cents (I think) and multiply with 100 to get dollars but I also have foreign currency so listing listing ordered by price becomes inconvenient when articles have different currencies and even are listed as price per hour or per item. So

Python - Convert currency code to its sign

陌路散爱 提交于 2019-12-18 11:47:34
问题 In Python, how can I convert currency code to its sign? For example, USD would be converted to $ , and JPY would be converted to ¥ . If there isn't a generic way to do this, is there any simple dictionary of these on the Web? Thanks. 回答1: Using the locale module: import locale locales=('en_AU.utf8', 'en_BW.utf8', 'en_CA.utf8', 'en_DK.utf8', 'en_GB.utf8', 'en_HK.utf8', 'en_IE.utf8', 'en_IN', 'en_NG', 'en_PH.utf8', 'en_US.utf8', 'en_ZA.utf8', 'en_ZW.utf8', 'ja_JP.utf8') for l in locales: locale