From fc570b9e2ec30c120142cafe0313b369d41eb188 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 22 Feb 2017 11:59:50 -0400 Subject: [PATCH 1/4] JSR-354 Java Money & Currency --- .../.resourceCache/ECBCurrentRateProvider.dat | 42 +++++ .../ECBHistoric90RateProvider.dat | 63 ++++++++ .../IMFHistoricRateProvider.dat | 118 ++++++++++++++ core-java/.resourceCache/IMFRateProvider.dat | 118 ++++++++++++++ core-java/pom.xml | 6 + .../java/com/baeldung/money/JavaMoney.java | 147 ++++++++++++++++++ .../com/baeldung/money/JavaMoneyTest.java | 58 +++++++ 7 files changed, 552 insertions(+) create mode 100644 core-java/.resourceCache/ECBCurrentRateProvider.dat create mode 100644 core-java/.resourceCache/ECBHistoric90RateProvider.dat create mode 100644 core-java/.resourceCache/IMFHistoricRateProvider.dat create mode 100644 core-java/.resourceCache/IMFRateProvider.dat create mode 100644 core-java/src/main/java/com/baeldung/money/JavaMoney.java create mode 100644 core-java/src/test/java/com/baeldung/money/JavaMoneyTest.java diff --git a/core-java/.resourceCache/ECBCurrentRateProvider.dat b/core-java/.resourceCache/ECBCurrentRateProvider.dat new file mode 100644 index 0000000000..37d1d8c8ab --- /dev/null +++ b/core-java/.resourceCache/ECBCurrentRateProvider.dat @@ -0,0 +1,42 @@ + + + Reference rates + + European Central Bank + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java/.resourceCache/ECBHistoric90RateProvider.dat b/core-java/.resourceCache/ECBHistoric90RateProvider.dat new file mode 100644 index 0000000000..16edc6a30a --- /dev/null +++ b/core-java/.resourceCache/ECBHistoric90RateProvider.dat @@ -0,0 +1,63 @@ +Reference ratesEuropean Central Bank + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java/.resourceCache/IMFHistoricRateProvider.dat b/core-java/.resourceCache/IMFHistoricRateProvider.dat new file mode 100644 index 0000000000..1db358b58b --- /dev/null +++ b/core-java/.resourceCache/IMFHistoricRateProvider.dat @@ -0,0 +1,118 @@ +SDRs per Currency unit and Currency units per SDR (1) +last five days +SDRs per Currency unit (2) + +Currency February 22, 2017 February 21, 2017 February 17, 2017 February 16, 2017 February 15, 2017 +Chinese Yuan 0.1077740000 0.1075920000 0.1074250000 0.1075990000 0.1078580000 +Euro 0.7806080000 0.7860480000 0.7864600000 0.7819020000 +Japanese Yen 0.0065267800 0.0065271000 0.0065062900 0.0064850300 0.0064793800 +U.K. Pound Sterling 0.9217470000 0.9201430000 0.9163910000 0.9224580000 0.9204290000 +U.S. Dollar 0.7413120000 0.7408260000 0.7380730000 0.7383210000 0.7407880000 +Algerian Dinar 0.0067122300 0.0067137500 0.0067192300 0.0067098500 +Australian Dollar 0.5680650000 0.5689800000 0.5694670000 0.5682580000 +Bahrain Dinar 1.9702800000 1.9629600000 1.9636200000 1.9701800000 +Botswana Pula 0.0708970000 0.0709288000 0.0712480000 0.0711156000 +Brazilian Real 0.2396560000 0.2419590000 0.2399250000 0.2389790000 +Brunei Dollar 0.5214510000 0.5207230000 0.5201640000 0.5219390000 +Canadian Dollar 0.5634090000 0.5627270000 0.5661790000 +Chilean Peso 0.0011535600 0.0011562200 0.0011537500 +Colombian Peso 0.0002552100 0.0002566600 0.0002567150 0.0002583270 +Czech Koruna 0.0288889000 0.0290901000 0.0291136000 +Danish Krone 0.1050150000 0.1057460000 0.1057900000 0.1051720000 +Hungarian Forint 0.0025387300 0.0025516800 0.0025498900 0.0025358200 +Icelandic Krona 0.0066885700 0.0066860500 0.0066725800 0.0066218600 +Indian Rupee 0.0110083000 0.0110285000 0.0110699000 +Indonesian Rupiah 0.0000554096 0.0000553776 0.0000553921 +Iranian Rial 0.0000228671 0.0000227947 0.0000228695 +Israeli New Sheqel 0.1998450000 0.1986200000 0.1986870000 0.1977020000 +Kazakhstani Tenge 0.0023350800 0.0023165400 0.0023114400 0.0023099100 +Korean Won 0.0006455440 0.0006480580 0.0006467420 0.0006472590 +Kuwaiti Dinar 2.4257600000 2.4171400000 2.4179500000 2.4248400000 +Libyan Dinar 0.5174910000 0.5174910000 0.5174910000 0.5174910000 +Malaysian Ringgit 0.1661230000 0.1655610000 0.1656540000 0.1664690000 +Mauritian Rupee 0.0207521000 0.0207775000 0.0208634000 +Mexican Peso 0.0360870000 0.0364464000 +Nepalese Rupee 0.0069139200 0.0068914400 0.0068937500 0.0069148500 +New Zealand Dollar 0.5306540000 0.5322980000 0.5342490000 0.5300340000 +Norwegian Krone 0.0885668000 0.0886734000 0.0886755000 0.0883278000 +Rial Omani 1.9267300000 1.9195700000 1.9202100000 1.9266300000 +Pakistani Rupee 0.0070658600 0.0070405000 0.0070429300 0.0070671000 +Nuevo Sol 0.2264720000 +Philippine Peso 0.0147628000 0.0147836000 0.0148472000 +Polish Zloty 0.1809450000 0.1813760000 0.1820000000 0.1817800000 +Qatar Riyal 0.2035240000 0.2027670000 0.2028350000 0.2035130000 +Russian Ruble 0.0128040000 0.0128062000 0.0129188000 0.0130485000 +Saudi Arabian Riyal 0.1975540000 0.1968190000 0.1968860000 0.1975430000 +Singapore Dollar 0.5214510000 0.5207230000 0.5201640000 0.5219390000 +South African Rand 0.0562263000 0.0562860000 0.0569367000 0.0568608000 +Sri Lanka Rupee 0.0049020900 0.0048960700 0.0048979200 0.0049141600 +Swedish Krona 0.0824973000 0.0830639000 0.0829146000 0.0828400000 +Swiss Franc 0.7337090000 0.7385900000 0.7376570000 0.7341080000 +Thai Baht 0.0211393000 0.0210914000 0.0210961000 0.0211545000 +Trinidad And Tobago Dollar 0.1095510000 0.1093120000 0.1094000000 0.1097660000 +Tunisian Dinar 0.3234230000 0.3229230000 0.3212750000 0.3239130000 +U.A.E. Dirham 0.2017230000 0.2009730000 0.2010400000 0.2017120000 +Peso Uruguayo 0.0260937000 0.0260969000 +Bolivar Fuerte 0.0740171000 0.0742645000 + +Currency units per SDR(3) + +Currency February 22, 2017 February 21, 2017 February 17, 2017 February 16, 2017 February 15, 2017 +Chinese Yuan 9.278680 9.294370 9.308820 9.293770 9.271450 +Euro 1.281050 1.272190 1.271520 1.278930 +Japanese Yen 153.215000 153.207000 153.697000 154.201000 154.336000 +U.K. Pound Sterling 1.084900 1.086790 1.091240 1.084060 1.086450 +U.S. Dollar 1.348960 1.349840 1.354880 1.354420 1.349910 +Algerian Dinar 148.982000 148.948000 148.827000 149.035000 +Australian Dollar 1.760360 1.757530 1.756030 1.759760 +Bahrain Dinar 0.507542 0.509435 0.509264 0.507568 +Botswana Pula 14.105000 14.098600 14.035500 14.061600 +Brazilian Real 4.172650 4.132930 4.167970 4.184470 +Brunei Dollar 1.917730 1.920410 1.922470 1.915930 +Canadian Dollar 1.774910 1.777060 1.766230 +Chilean Peso 866.882000 864.887000 866.739000 +Colombian Peso 3,918.340000 3,896.210000 3,895.370000 3,871.060000 +Czech Koruna 34.615400 34.376000 34.348200 +Danish Krone 9.522450 9.456620 9.452690 9.508230 +Hungarian Forint 393.898000 391.899000 392.174000 394.350000 +Icelandic Krona 149.509000 149.565000 149.867000 151.015000 +Indian Rupee 90.840500 90.674200 90.335100 +Indonesian Rupiah 18,047.400000 18,057.800000 18,053.100000 +Iranian Rial 43,730.900000 43,869.800000 43,726.400000 +Israeli New Sheqel 5.003880 5.034740 5.033040 5.058120 +Kazakhstani Tenge 428.251000 431.678000 432.631000 432.917000 +Korean Won 1,549.080000 1,543.070000 1,546.210000 1,544.980000 +Kuwaiti Dinar 0.412242 0.413712 0.413573 0.412398 +Libyan Dinar 1.932400 1.932400 1.932400 1.932400 +Malaysian Ringgit 6.019640 6.040070 6.036680 6.007120 +Mauritian Rupee 48.187900 48.129000 47.930800 +Mexican Peso 27.710800 27.437600 +Nepalese Rupee 144.636000 145.108000 145.059000 144.616000 +New Zealand Dollar 1.884470 1.878650 1.871790 1.886670 +Norwegian Krone 11.290900 11.277300 11.277100 11.321500 +Rial Omani 0.519014 0.520950 0.520776 0.519041 +Pakistani Rupee 141.526000 142.035000 141.986000 141.501000 +Nuevo Sol 4.415560 +Philippine Peso 67.737800 67.642500 67.352800 +Polish Zloty 5.526540 5.513410 5.494510 5.501160 +Qatar Riyal 4.913430 4.931770 4.930120 4.913690 +Russian Ruble 78.100600 78.087200 77.406600 76.637200 +Saudi Arabian Riyal 5.061910 5.080810 5.079080 5.062190 +Singapore Dollar 1.917730 1.920410 1.922470 1.915930 +South African Rand 17.785300 17.766400 17.563400 17.586800 +Sri Lanka Rupee 203.995000 204.245000 204.168000 203.494000 +Swedish Krona 12.121600 12.038900 12.060600 12.071500 +Swiss Franc 1.362940 1.353930 1.355640 1.362200 +Thai Baht 47.305300 47.412700 47.402100 47.271300 +Trinidad And Tobago Dollar 9.128170 9.148130 9.140770 9.110290 +Tunisian Dinar 3.091930 3.096710 3.112600 3.087250 +U.A.E. Dirham 4.957290 4.975790 4.974130 4.957560 +Peso Uruguayo 38.323400 38.318700 +Bolivar Fuerte 13.510400 13.465400 + + +(1) Exchange rates are published daily except on IMF holidays or whenever the IMF is closed for business. + +(2) The value of the U.S. dollar in terms of the SDR is the reciprocal of the sum of the dollar values, based on market exchange rates, of specified quantities of the SDR basket currencies. See SDR Valuation.The value in terms of the SDR of each of the other currencies shown above is derived from that currency's representative exchange rate against the U.S. dollar as reported by the issuing central bank and the SDR value of the U.S. dollar, except for the Iranian rial and the Libyan dinar, the values of which are officially expressed directly in terms of domestic currency units per SDR. All figures are rounded to six significant digits. See Representative Exchange Rates for Selected Currencies". + +(3) The value in terms of each national currency of the SDR is the reciprocal of the value in terms of the SDR of each national currency, rounded to six significant digits. \ No newline at end of file diff --git a/core-java/.resourceCache/IMFRateProvider.dat b/core-java/.resourceCache/IMFRateProvider.dat new file mode 100644 index 0000000000..1db358b58b --- /dev/null +++ b/core-java/.resourceCache/IMFRateProvider.dat @@ -0,0 +1,118 @@ +SDRs per Currency unit and Currency units per SDR (1) +last five days +SDRs per Currency unit (2) + +Currency February 22, 2017 February 21, 2017 February 17, 2017 February 16, 2017 February 15, 2017 +Chinese Yuan 0.1077740000 0.1075920000 0.1074250000 0.1075990000 0.1078580000 +Euro 0.7806080000 0.7860480000 0.7864600000 0.7819020000 +Japanese Yen 0.0065267800 0.0065271000 0.0065062900 0.0064850300 0.0064793800 +U.K. Pound Sterling 0.9217470000 0.9201430000 0.9163910000 0.9224580000 0.9204290000 +U.S. Dollar 0.7413120000 0.7408260000 0.7380730000 0.7383210000 0.7407880000 +Algerian Dinar 0.0067122300 0.0067137500 0.0067192300 0.0067098500 +Australian Dollar 0.5680650000 0.5689800000 0.5694670000 0.5682580000 +Bahrain Dinar 1.9702800000 1.9629600000 1.9636200000 1.9701800000 +Botswana Pula 0.0708970000 0.0709288000 0.0712480000 0.0711156000 +Brazilian Real 0.2396560000 0.2419590000 0.2399250000 0.2389790000 +Brunei Dollar 0.5214510000 0.5207230000 0.5201640000 0.5219390000 +Canadian Dollar 0.5634090000 0.5627270000 0.5661790000 +Chilean Peso 0.0011535600 0.0011562200 0.0011537500 +Colombian Peso 0.0002552100 0.0002566600 0.0002567150 0.0002583270 +Czech Koruna 0.0288889000 0.0290901000 0.0291136000 +Danish Krone 0.1050150000 0.1057460000 0.1057900000 0.1051720000 +Hungarian Forint 0.0025387300 0.0025516800 0.0025498900 0.0025358200 +Icelandic Krona 0.0066885700 0.0066860500 0.0066725800 0.0066218600 +Indian Rupee 0.0110083000 0.0110285000 0.0110699000 +Indonesian Rupiah 0.0000554096 0.0000553776 0.0000553921 +Iranian Rial 0.0000228671 0.0000227947 0.0000228695 +Israeli New Sheqel 0.1998450000 0.1986200000 0.1986870000 0.1977020000 +Kazakhstani Tenge 0.0023350800 0.0023165400 0.0023114400 0.0023099100 +Korean Won 0.0006455440 0.0006480580 0.0006467420 0.0006472590 +Kuwaiti Dinar 2.4257600000 2.4171400000 2.4179500000 2.4248400000 +Libyan Dinar 0.5174910000 0.5174910000 0.5174910000 0.5174910000 +Malaysian Ringgit 0.1661230000 0.1655610000 0.1656540000 0.1664690000 +Mauritian Rupee 0.0207521000 0.0207775000 0.0208634000 +Mexican Peso 0.0360870000 0.0364464000 +Nepalese Rupee 0.0069139200 0.0068914400 0.0068937500 0.0069148500 +New Zealand Dollar 0.5306540000 0.5322980000 0.5342490000 0.5300340000 +Norwegian Krone 0.0885668000 0.0886734000 0.0886755000 0.0883278000 +Rial Omani 1.9267300000 1.9195700000 1.9202100000 1.9266300000 +Pakistani Rupee 0.0070658600 0.0070405000 0.0070429300 0.0070671000 +Nuevo Sol 0.2264720000 +Philippine Peso 0.0147628000 0.0147836000 0.0148472000 +Polish Zloty 0.1809450000 0.1813760000 0.1820000000 0.1817800000 +Qatar Riyal 0.2035240000 0.2027670000 0.2028350000 0.2035130000 +Russian Ruble 0.0128040000 0.0128062000 0.0129188000 0.0130485000 +Saudi Arabian Riyal 0.1975540000 0.1968190000 0.1968860000 0.1975430000 +Singapore Dollar 0.5214510000 0.5207230000 0.5201640000 0.5219390000 +South African Rand 0.0562263000 0.0562860000 0.0569367000 0.0568608000 +Sri Lanka Rupee 0.0049020900 0.0048960700 0.0048979200 0.0049141600 +Swedish Krona 0.0824973000 0.0830639000 0.0829146000 0.0828400000 +Swiss Franc 0.7337090000 0.7385900000 0.7376570000 0.7341080000 +Thai Baht 0.0211393000 0.0210914000 0.0210961000 0.0211545000 +Trinidad And Tobago Dollar 0.1095510000 0.1093120000 0.1094000000 0.1097660000 +Tunisian Dinar 0.3234230000 0.3229230000 0.3212750000 0.3239130000 +U.A.E. Dirham 0.2017230000 0.2009730000 0.2010400000 0.2017120000 +Peso Uruguayo 0.0260937000 0.0260969000 +Bolivar Fuerte 0.0740171000 0.0742645000 + +Currency units per SDR(3) + +Currency February 22, 2017 February 21, 2017 February 17, 2017 February 16, 2017 February 15, 2017 +Chinese Yuan 9.278680 9.294370 9.308820 9.293770 9.271450 +Euro 1.281050 1.272190 1.271520 1.278930 +Japanese Yen 153.215000 153.207000 153.697000 154.201000 154.336000 +U.K. Pound Sterling 1.084900 1.086790 1.091240 1.084060 1.086450 +U.S. Dollar 1.348960 1.349840 1.354880 1.354420 1.349910 +Algerian Dinar 148.982000 148.948000 148.827000 149.035000 +Australian Dollar 1.760360 1.757530 1.756030 1.759760 +Bahrain Dinar 0.507542 0.509435 0.509264 0.507568 +Botswana Pula 14.105000 14.098600 14.035500 14.061600 +Brazilian Real 4.172650 4.132930 4.167970 4.184470 +Brunei Dollar 1.917730 1.920410 1.922470 1.915930 +Canadian Dollar 1.774910 1.777060 1.766230 +Chilean Peso 866.882000 864.887000 866.739000 +Colombian Peso 3,918.340000 3,896.210000 3,895.370000 3,871.060000 +Czech Koruna 34.615400 34.376000 34.348200 +Danish Krone 9.522450 9.456620 9.452690 9.508230 +Hungarian Forint 393.898000 391.899000 392.174000 394.350000 +Icelandic Krona 149.509000 149.565000 149.867000 151.015000 +Indian Rupee 90.840500 90.674200 90.335100 +Indonesian Rupiah 18,047.400000 18,057.800000 18,053.100000 +Iranian Rial 43,730.900000 43,869.800000 43,726.400000 +Israeli New Sheqel 5.003880 5.034740 5.033040 5.058120 +Kazakhstani Tenge 428.251000 431.678000 432.631000 432.917000 +Korean Won 1,549.080000 1,543.070000 1,546.210000 1,544.980000 +Kuwaiti Dinar 0.412242 0.413712 0.413573 0.412398 +Libyan Dinar 1.932400 1.932400 1.932400 1.932400 +Malaysian Ringgit 6.019640 6.040070 6.036680 6.007120 +Mauritian Rupee 48.187900 48.129000 47.930800 +Mexican Peso 27.710800 27.437600 +Nepalese Rupee 144.636000 145.108000 145.059000 144.616000 +New Zealand Dollar 1.884470 1.878650 1.871790 1.886670 +Norwegian Krone 11.290900 11.277300 11.277100 11.321500 +Rial Omani 0.519014 0.520950 0.520776 0.519041 +Pakistani Rupee 141.526000 142.035000 141.986000 141.501000 +Nuevo Sol 4.415560 +Philippine Peso 67.737800 67.642500 67.352800 +Polish Zloty 5.526540 5.513410 5.494510 5.501160 +Qatar Riyal 4.913430 4.931770 4.930120 4.913690 +Russian Ruble 78.100600 78.087200 77.406600 76.637200 +Saudi Arabian Riyal 5.061910 5.080810 5.079080 5.062190 +Singapore Dollar 1.917730 1.920410 1.922470 1.915930 +South African Rand 17.785300 17.766400 17.563400 17.586800 +Sri Lanka Rupee 203.995000 204.245000 204.168000 203.494000 +Swedish Krona 12.121600 12.038900 12.060600 12.071500 +Swiss Franc 1.362940 1.353930 1.355640 1.362200 +Thai Baht 47.305300 47.412700 47.402100 47.271300 +Trinidad And Tobago Dollar 9.128170 9.148130 9.140770 9.110290 +Tunisian Dinar 3.091930 3.096710 3.112600 3.087250 +U.A.E. Dirham 4.957290 4.975790 4.974130 4.957560 +Peso Uruguayo 38.323400 38.318700 +Bolivar Fuerte 13.510400 13.465400 + + +(1) Exchange rates are published daily except on IMF holidays or whenever the IMF is closed for business. + +(2) The value of the U.S. dollar in terms of the SDR is the reciprocal of the sum of the dollar values, based on market exchange rates, of specified quantities of the SDR basket currencies. See SDR Valuation.The value in terms of the SDR of each of the other currencies shown above is derived from that currency's representative exchange rate against the U.S. dollar as reported by the issuing central bank and the SDR value of the U.S. dollar, except for the Iranian rial and the Libyan dinar, the values of which are officially expressed directly in terms of domestic currency units per SDR. All figures are rounded to six significant digits. See Representative Exchange Rates for Selected Currencies". + +(3) The value in terms of each national currency of the SDR is the reciprocal of the value in terms of the SDR of each national currency, rounded to six significant digits. \ No newline at end of file diff --git a/core-java/pom.xml b/core-java/pom.xml index b2c59989f1..225eb3fc29 100644 --- a/core-java/pom.xml +++ b/core-java/pom.xml @@ -165,6 +165,12 @@ commons-codec ${commons-codec.version} + + + org.javamoney + moneta + 1.1 + diff --git a/core-java/src/main/java/com/baeldung/money/JavaMoney.java b/core-java/src/main/java/com/baeldung/money/JavaMoney.java new file mode 100644 index 0000000000..f66480bea5 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/money/JavaMoney.java @@ -0,0 +1,147 @@ +package com.baeldung.money; + +import java.util.Locale; +import java.util.logging.Logger; + +import javax.money.CurrencyUnit; +import javax.money.Monetary; +import javax.money.MonetaryAmount; +import javax.money.UnknownCurrencyException; +import javax.money.convert.ConversionQueryBuilder; +import javax.money.convert.CurrencyConversion; +import javax.money.convert.MonetaryConversions; +import javax.money.format.AmountFormatQueryBuilder; +import javax.money.format.MonetaryAmountFormat; +import javax.money.format.MonetaryFormats; + +import org.javamoney.moneta.FastMoney; +import org.javamoney.moneta.Money; +import org.javamoney.moneta.format.CurrencyStyle; + +public class JavaMoney { + final static Logger LOGGER = Logger.getLogger(JavaMoney.class.getName()); + CurrencyUnit USD; + MonetaryAmount fstAmtUSD; + MonetaryAmount fstAmtEUR; + MonetaryAmount oneDolar; + MonetaryAmount moneyof; + MonetaryAmount fastmoneyof; + MonetaryAmount roundEUR; + MonetaryAmount calcAmtUSD; + MonetaryAmount[] monetaryAmounts; + MonetaryAmount sumAmtCHF; + MonetaryAmount calcMoneyFastMoney; + MonetaryAmount convertedAmountEURtoUSD; + MonetaryAmount convertedAmountEURtoUSD2; + MonetaryAmount convertedAmountUSDtoEUR; + MonetaryAmount convertedAmountUSDtoEUR2; + MonetaryAmount multiplyAmount; + MonetaryAmount divideAmount; + MonetaryAmount oneDivThree; + CurrencyConversion convEUR; + CurrencyConversion convUSD; + CurrencyConversion conversionUSD; + CurrencyConversion conversionEUR; + MonetaryAmount oneEuro; + MonetaryAmountFormat formatUSD; + MonetaryAmountFormat customFormat; + String usFormatted; + String customFormatted; + + public JavaMoney() { + USD = Monetary.getCurrency("USD"); + fstAmtUSD = Monetary.getDefaultAmountFactory().setCurrency(USD).setNumber(200.50).create(); + fstAmtEUR = Monetary.getDefaultAmountFactory().setCurrency("EUR").setNumber(1.30473908).create(); + oneDolar = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(1).create(); + moneyof = Money.of(12, USD); + fastmoneyof = FastMoney.of(2, USD); + + LOGGER.info("First Amount in USD : " + fstAmtUSD); + LOGGER.info("First Amount in EUR : " + fstAmtEUR); + LOGGER.info("One Dolar : " + oneDolar); + LOGGER.info("MoneyOf : " + moneyof); + LOGGER.info("FastMoneyOf : " + fastmoneyof); + + try{ + @SuppressWarnings("unused") + CurrencyUnit AAA = Monetary.getCurrency("AAA"); + } catch (UnknownCurrencyException e) { + LOGGER.severe("Unknown Currency"); + } + + roundEUR = fstAmtEUR.with(Monetary.getDefaultRounding()); + + LOGGER.info("Rounded EUR : " + roundEUR); + + calcAmtUSD = Money.of(1, "USD").subtract(fstAmtUSD); + + LOGGER.info("Substracting amounts : " + calcAmtUSD); + + calcMoneyFastMoney = moneyof.subtract(fastmoneyof); + + LOGGER.info("Money & FastMoney operations : " + calcMoneyFastMoney); + + monetaryAmounts = new MonetaryAmount[] { Money.of(100, "CHF"), Money.of(10.20, "CHF"), Money.of(1.15, "CHF"), }; + sumAmtCHF = Money.of(0, "CHF"); + for (MonetaryAmount monetaryAmount : monetaryAmounts) { + sumAmtCHF = sumAmtCHF.add(monetaryAmount); + } + + LOGGER.info("Adding amounts : " + sumAmtCHF); + + multiplyAmount = oneDolar.multiply(0.25); + LOGGER.info("Multiply Amount : " + multiplyAmount); + + divideAmount = oneDolar.divide(0.25); + LOGGER.info("Divide Amount : " + divideAmount); + + try{ + oneDivThree = oneDolar.divide(3); + }catch (ArithmeticException e) { + LOGGER.severe("One divide by Three is an infinite number"); + } + + convEUR = MonetaryConversions.getConversion(ConversionQueryBuilder.of().setTermCurrency("EUR").build()); + convUSD = MonetaryConversions.getConversion(ConversionQueryBuilder.of().setTermCurrency(USD).build()); + + conversionUSD = MonetaryConversions.getConversion("USD"); + conversionEUR = MonetaryConversions.getConversion("EUR"); + + convertedAmountEURtoUSD = fstAmtEUR.with(conversionUSD); + convertedAmountEURtoUSD2 = fstAmtEUR.with(convUSD); + convertedAmountUSDtoEUR = oneDolar.with(conversionEUR); + convertedAmountUSDtoEUR2 = oneDolar.with(convEUR); + LOGGER.info("C1 - " + convertedAmountEURtoUSD); + LOGGER.info("C2 - " + convertedAmountEURtoUSD2); + LOGGER.info("One Euro -> " + convertedAmountUSDtoEUR); + LOGGER.info("One Euro2 -> " + convertedAmountUSDtoEUR2); + + oneEuro = Money.of(1, "EUR"); + + if (oneEuro.equals(FastMoney.of(1, "EUR"))) { + LOGGER.info("Money == FastMoney"); + } else { + LOGGER.info("Money != FastMoney"); + } + + if (oneDolar.equals(Money.of(1, "USD"))) { + LOGGER.info("Factory == Money"); + } else { + LOGGER.info("Factory != Money"); + } + + formatUSD = MonetaryFormats.getAmountFormat(Locale.US); + usFormatted = formatUSD.format(oneDolar); + LOGGER.info("One dolar standard formatted : " + usFormatted); + + customFormat = MonetaryFormats.getAmountFormat(AmountFormatQueryBuilder.of(Locale.US).set(CurrencyStyle.NAME).set("pattern", "00000.00 ค").build()); + customFormatted = customFormat.format(oneDolar); + LOGGER.info("One dolar custom formatted : " + customFormatted); + } + + public static void main(String[] args) { + @SuppressWarnings("unused") + JavaMoney java9Money = new JavaMoney(); + } + +} diff --git a/core-java/src/test/java/com/baeldung/money/JavaMoneyTest.java b/core-java/src/test/java/com/baeldung/money/JavaMoneyTest.java new file mode 100644 index 0000000000..25fcd48f7a --- /dev/null +++ b/core-java/src/test/java/com/baeldung/money/JavaMoneyTest.java @@ -0,0 +1,58 @@ +package com.baeldung.money; + +import javax.money.convert.ConversionQueryBuilder; +import javax.money.convert.MonetaryConversions; + +import com.baeldung.money.JavaMoney; + +import junit.framework.TestCase; + +public class JavaMoneyTest + extends TestCase +{ + JavaMoney j9m; + public JavaMoneyTest( String testName ) + { + super( testName ); + j9m = new JavaMoney(); + } + + public void testAmounts() + { + assertEquals("USD", j9m.USD.toString()); + assertEquals("USD 1", j9m.oneDolar.toString()); + assertEquals("EUR 1", j9m.oneEuro.toString()); + assertEquals("USD 200.5", j9m.fstAmtUSD.toString()); + assertEquals("EUR 1.30473908", j9m.fstAmtEUR.toString()); + assertEquals("USD 12", j9m.moneyof.toString()); + assertEquals("USD 2.00000", j9m.fastmoneyof.toString()); + + } + + public void testArithmetic(){ + assertEquals("USD -199.5", j9m.calcAmtUSD.toString()); + assertEquals("CHF 111.35", j9m.sumAmtCHF.toString()); + assertEquals("USD 10", j9m.calcMoneyFastMoney.toString()); + assertEquals("USD 0.25", j9m.multiplyAmount.toString()); + assertEquals("USD 4", j9m.divideAmount.toString()); + } + + public void testRounding(){ + assertEquals("EUR 1.3", j9m.roundEUR.toString()); + } + + public void testFormatting(){ + assertEquals("USD1.00", j9m.usFormatted); + assertEquals("00001.00 US Dollar", j9m.customFormatted); + } + + public void testConversion(){ + + assertNotNull(MonetaryConversions.getConversion(ConversionQueryBuilder.of().setTermCurrency("EUR").build())); + assertNotNull(MonetaryConversions.getConversion(ConversionQueryBuilder.of().setTermCurrency("USD").build())); + assertNotNull(j9m.convertedAmountEURtoUSD); + assertNotNull(j9m.convertedAmountEURtoUSD2); + assertNotNull(j9m.convertedAmountUSDtoEUR); + assertNotNull(j9m.convertedAmountUSDtoEUR2); + } +} From bb1b9c4ca43f5f3f2bb0acb2d7d28336de97f061 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 27 Feb 2017 15:13:19 -0400 Subject: [PATCH 2/4] Java Money & Currency --- .../.resourceCache/ECBCurrentRateProvider.dat | 60 +++--- .../ECBHistoric90RateProvider.dat | 10 +- .../IMFHistoricRateProvider.dat | 204 +++++++++--------- core-java/.resourceCache/IMFRateProvider.dat | 204 +++++++++--------- .../java/com/baeldung/money/JavaMoney.java | 8 +- .../com/baeldung/money/JavaMoneyTest.java | 37 ++-- 6 files changed, 269 insertions(+), 254 deletions(-) diff --git a/core-java/.resourceCache/ECBCurrentRateProvider.dat b/core-java/.resourceCache/ECBCurrentRateProvider.dat index 37d1d8c8ab..45cf516ac8 100644 --- a/core-java/.resourceCache/ECBCurrentRateProvider.dat +++ b/core-java/.resourceCache/ECBCurrentRateProvider.dat @@ -5,38 +5,38 @@ European Central Bank - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java/.resourceCache/ECBHistoric90RateProvider.dat b/core-java/.resourceCache/ECBHistoric90RateProvider.dat index 16edc6a30a..f51c2eacfa 100644 --- a/core-java/.resourceCache/ECBHistoric90RateProvider.dat +++ b/core-java/.resourceCache/ECBHistoric90RateProvider.dat @@ -1,4 +1,7 @@ -Reference ratesEuropean Central Bank +Reference ratesEuropean Central Bank + + + @@ -57,7 +60,4 @@ - - - - \ No newline at end of file + \ No newline at end of file diff --git a/core-java/.resourceCache/IMFHistoricRateProvider.dat b/core-java/.resourceCache/IMFHistoricRateProvider.dat index 1db358b58b..4c98b3b04e 100644 --- a/core-java/.resourceCache/IMFHistoricRateProvider.dat +++ b/core-java/.resourceCache/IMFHistoricRateProvider.dat @@ -2,113 +2,113 @@ SDRs per Currency unit and Currency units per SDR (1) last five days SDRs per Currency unit (2) -Currency February 22, 2017 February 21, 2017 February 17, 2017 February 16, 2017 February 15, 2017 -Chinese Yuan 0.1077740000 0.1075920000 0.1074250000 0.1075990000 0.1078580000 -Euro 0.7806080000 0.7860480000 0.7864600000 0.7819020000 -Japanese Yen 0.0065267800 0.0065271000 0.0065062900 0.0064850300 0.0064793800 -U.K. Pound Sterling 0.9217470000 0.9201430000 0.9163910000 0.9224580000 0.9204290000 -U.S. Dollar 0.7413120000 0.7408260000 0.7380730000 0.7383210000 0.7407880000 -Algerian Dinar 0.0067122300 0.0067137500 0.0067192300 0.0067098500 -Australian Dollar 0.5680650000 0.5689800000 0.5694670000 0.5682580000 -Bahrain Dinar 1.9702800000 1.9629600000 1.9636200000 1.9701800000 -Botswana Pula 0.0708970000 0.0709288000 0.0712480000 0.0711156000 -Brazilian Real 0.2396560000 0.2419590000 0.2399250000 0.2389790000 -Brunei Dollar 0.5214510000 0.5207230000 0.5201640000 0.5219390000 -Canadian Dollar 0.5634090000 0.5627270000 0.5661790000 -Chilean Peso 0.0011535600 0.0011562200 0.0011537500 -Colombian Peso 0.0002552100 0.0002566600 0.0002567150 0.0002583270 -Czech Koruna 0.0288889000 0.0290901000 0.0291136000 -Danish Krone 0.1050150000 0.1057460000 0.1057900000 0.1051720000 -Hungarian Forint 0.0025387300 0.0025516800 0.0025498900 0.0025358200 -Icelandic Krona 0.0066885700 0.0066860500 0.0066725800 0.0066218600 -Indian Rupee 0.0110083000 0.0110285000 0.0110699000 -Indonesian Rupiah 0.0000554096 0.0000553776 0.0000553921 -Iranian Rial 0.0000228671 0.0000227947 0.0000228695 -Israeli New Sheqel 0.1998450000 0.1986200000 0.1986870000 0.1977020000 -Kazakhstani Tenge 0.0023350800 0.0023165400 0.0023114400 0.0023099100 -Korean Won 0.0006455440 0.0006480580 0.0006467420 0.0006472590 -Kuwaiti Dinar 2.4257600000 2.4171400000 2.4179500000 2.4248400000 +Currency February 27, 2017 February 24, 2017 February 23, 2017 February 22, 2017 February 21, 2017 +Chinese Yuan 0.1075530000 0.1074200000 0.1076250000 0.1077740000 0.1075920000 +Euro 0.7826360000 0.7829640000 0.7824120000 0.7793410000 0.7806080000 +Japanese Yen 0.0065915500 0.0065398200 0.0065279600 0.0065267800 0.0065271000 +U.K. Pound Sterling 0.9178430000 0.9263250000 0.9233090000 0.9217470000 0.9201430000 +U.S. Dollar 0.7392420000 0.7380190000 0.7400090000 0.7413120000 0.7408260000 +Algerian Dinar 0.0067056800 0.0067170500 0.0067108200 0.0067122300 +Australian Dollar 0.5695290000 0.5688450000 0.5701430000 0.5680650000 +Bahrain Dinar 1.9628200000 1.9681100000 1.9715700000 1.9702800000 +Botswana Pula 0.0712926000 0.0714849000 0.0710918000 0.0708970000 +Brazilian Real 0.2409310000 0.2401220000 0.2394110000 0.2396560000 +Brunei Dollar 0.5253930000 0.5230480000 0.5224920000 0.5214510000 +Canadian Dollar 0.5632010000 0.5645050000 0.5621540000 0.5634090000 +Chilean Peso 0.0011525100 0.0011535400 0.0011517700 0.0011535600 +Colombian Peso 0.0002570000 0.0002557440 0.0002553890 0.0002552100 +Czech Koruna 0.0289783000 0.0289564000 0.0288448000 0.0288889000 +Danish Krone 0.1053170000 0.1052550000 0.1048460000 0.1050150000 +Hungarian Forint 0.0025337100 0.0025343600 0.0025357900 0.0025387300 +Icelandic Krona 0.0068082900 0.0067593100 0.0067227000 0.0066885700 +Indian Rupee 0.0110722000 0.0110702000 +Indonesian Rupiah 0.0000553404 0.0000553899 0.0000555040 0.0000554096 +Iranian Rial 0.0000228786 0.0000228671 +Israeli New Sheqel 0.1995720000 0.1995710000 0.1998150000 0.1998450000 +Kazakhstani Tenge 0.0023693200 0.0023668900 0.0023601900 0.0023350800 +Korean Won 0.0006480670 0.0006486190 0.0006464180 0.0006455440 +Kuwaiti Dinar 2.4165700000 2.4230800000 2.4273500000 2.4257600000 Libyan Dinar 0.5174910000 0.5174910000 0.5174910000 0.5174910000 -Malaysian Ringgit 0.1661230000 0.1655610000 0.1656540000 0.1664690000 -Mauritian Rupee 0.0207521000 0.0207775000 0.0208634000 -Mexican Peso 0.0360870000 0.0364464000 -Nepalese Rupee 0.0069139200 0.0068914400 0.0068937500 0.0069148500 -New Zealand Dollar 0.5306540000 0.5322980000 0.5342490000 0.5300340000 -Norwegian Krone 0.0885668000 0.0886734000 0.0886755000 0.0883278000 -Rial Omani 1.9267300000 1.9195700000 1.9202100000 1.9266300000 -Pakistani Rupee 0.0070658600 0.0070405000 0.0070429300 0.0070671000 -Nuevo Sol 0.2264720000 -Philippine Peso 0.0147628000 0.0147836000 0.0148472000 -Polish Zloty 0.1809450000 0.1813760000 0.1820000000 0.1817800000 -Qatar Riyal 0.2035240000 0.2027670000 0.2028350000 0.2035130000 -Russian Ruble 0.0128040000 0.0128062000 0.0129188000 0.0130485000 -Saudi Arabian Riyal 0.1975540000 0.1968190000 0.1968860000 0.1975430000 -Singapore Dollar 0.5214510000 0.5207230000 0.5201640000 0.5219390000 -South African Rand 0.0562263000 0.0562860000 0.0569367000 0.0568608000 -Sri Lanka Rupee 0.0049020900 0.0048960700 0.0048979200 0.0049141600 -Swedish Krona 0.0824973000 0.0830639000 0.0829146000 0.0828400000 -Swiss Franc 0.7337090000 0.7385900000 0.7376570000 0.7341080000 -Thai Baht 0.0211393000 0.0210914000 0.0210961000 0.0211545000 -Trinidad And Tobago Dollar 0.1095510000 0.1093120000 0.1094000000 0.1097660000 -Tunisian Dinar 0.3234230000 0.3229230000 0.3212750000 0.3239130000 -U.A.E. Dirham 0.2017230000 0.2009730000 0.2010400000 0.2017120000 -Peso Uruguayo 0.0260937000 0.0260969000 -Bolivar Fuerte 0.0740171000 0.0742645000 +Malaysian Ringgit 0.1659960000 0.1662940000 0.1663250000 0.1661230000 +Mauritian Rupee 0.0208418000 +Mexican Peso 0.0372107000 0.0375618000 0.0372281000 0.0362282000 +Nepalese Rupee 0.0069012400 0.0069030700 0.0069229700 0.0069139200 +New Zealand Dollar 0.5331450000 0.5322880000 0.5307790000 0.5306540000 +Norwegian Krone 0.0886062000 0.0888398000 0.0884082000 0.0885668000 +Rial Omani 1.9194300000 1.9246000000 1.9279900000 1.9267300000 +Pakistani Rupee 0.0070384300 0.0070575400 0.0070700400 0.0070658600 +Nuevo Sol 0.2283980000 0.2287290000 0.2281570000 +Philippine Peso 0.0146922000 0.0147295000 0.0147363000 0.0147628000 +Polish Zloty 0.1814160000 0.1811970000 0.1812540000 0.1809450000 +Qatar Riyal 0.2027520000 0.2032990000 0.2036570000 0.2035240000 +Russian Ruble 0.0128977000 0.0128040000 +Saudi Arabian Riyal 0.1968050000 0.1973360000 0.1976830000 0.1975540000 +Singapore Dollar 0.5253930000 0.5230480000 0.5224920000 0.5214510000 +South African Rand 0.0569347000 0.0570889000 0.0566127000 0.0562263000 +Sri Lanka Rupee 0.0048931100 0.0049014800 0.0049020900 +Swedish Krona 0.0822544000 0.0824642000 0.0823543000 0.0824973000 +Swiss Franc 0.7345670000 0.7331180000 0.7312210000 0.7337090000 +Thai Baht 0.0211098000 0.0211467000 0.0211707000 0.0211393000 +Trinidad And Tobago Dollar 0.1092030000 0.1091300000 0.1093820000 0.1095510000 +Tunisian Dinar 0.3206630000 0.3204540000 0.3225790000 0.3234230000 +U.A.E. Dirham 0.2009580000 0.2015000000 0.2018550000 0.2017230000 +Peso Uruguayo 0.0259816000 0.0261108000 0.0261517000 +Bolivar Fuerte 0.0739869000 0.0741864000 Currency units per SDR(3) -Currency February 22, 2017 February 21, 2017 February 17, 2017 February 16, 2017 February 15, 2017 -Chinese Yuan 9.278680 9.294370 9.308820 9.293770 9.271450 -Euro 1.281050 1.272190 1.271520 1.278930 -Japanese Yen 153.215000 153.207000 153.697000 154.201000 154.336000 -U.K. Pound Sterling 1.084900 1.086790 1.091240 1.084060 1.086450 -U.S. Dollar 1.348960 1.349840 1.354880 1.354420 1.349910 -Algerian Dinar 148.982000 148.948000 148.827000 149.035000 -Australian Dollar 1.760360 1.757530 1.756030 1.759760 -Bahrain Dinar 0.507542 0.509435 0.509264 0.507568 -Botswana Pula 14.105000 14.098600 14.035500 14.061600 -Brazilian Real 4.172650 4.132930 4.167970 4.184470 -Brunei Dollar 1.917730 1.920410 1.922470 1.915930 -Canadian Dollar 1.774910 1.777060 1.766230 -Chilean Peso 866.882000 864.887000 866.739000 -Colombian Peso 3,918.340000 3,896.210000 3,895.370000 3,871.060000 -Czech Koruna 34.615400 34.376000 34.348200 -Danish Krone 9.522450 9.456620 9.452690 9.508230 -Hungarian Forint 393.898000 391.899000 392.174000 394.350000 -Icelandic Krona 149.509000 149.565000 149.867000 151.015000 -Indian Rupee 90.840500 90.674200 90.335100 -Indonesian Rupiah 18,047.400000 18,057.800000 18,053.100000 -Iranian Rial 43,730.900000 43,869.800000 43,726.400000 -Israeli New Sheqel 5.003880 5.034740 5.033040 5.058120 -Kazakhstani Tenge 428.251000 431.678000 432.631000 432.917000 -Korean Won 1,549.080000 1,543.070000 1,546.210000 1,544.980000 -Kuwaiti Dinar 0.412242 0.413712 0.413573 0.412398 +Currency February 27, 2017 February 24, 2017 February 23, 2017 February 22, 2017 February 21, 2017 +Chinese Yuan 9.297740 9.309250 9.291520 9.278680 9.294370 +Euro 1.277730 1.277200 1.278100 1.283140 1.281050 +Japanese Yen 151.709000 152.909000 153.187000 153.215000 153.207000 +U.K. Pound Sterling 1.089510 1.079530 1.083060 1.084900 1.086790 +U.S. Dollar 1.352740 1.354980 1.351330 1.348960 1.349840 +Algerian Dinar 149.127000 148.875000 149.013000 148.982000 +Australian Dollar 1.755840 1.757950 1.753950 1.760360 +Bahrain Dinar 0.509471 0.508102 0.507210 0.507542 +Botswana Pula 14.026700 13.989000 14.066300 14.105000 +Brazilian Real 4.150570 4.164550 4.176920 4.172650 +Brunei Dollar 1.903340 1.911870 1.913900 1.917730 +Canadian Dollar 1.775570 1.771460 1.778870 1.774910 +Chilean Peso 867.671000 866.897000 868.229000 866.882000 +Colombian Peso 3,891.050000 3,910.160000 3,915.600000 3,918.340000 +Czech Koruna 34.508600 34.534700 34.668300 34.615400 +Danish Krone 9.495140 9.500740 9.537800 9.522450 +Hungarian Forint 394.678000 394.577000 394.354000 393.898000 +Icelandic Krona 146.880000 147.944000 148.750000 149.509000 +Indian Rupee 90.316300 90.332600 +Indonesian Rupiah 18,070.000000 18,053.800000 18,016.700000 18,047.400000 +Iranian Rial 43,709.000000 43,730.900000 +Israeli New Sheqel 5.010720 5.010750 5.004630 5.003880 +Kazakhstani Tenge 422.062000 422.495000 423.695000 428.251000 +Korean Won 1,543.050000 1,541.740000 1,546.990000 1,549.080000 +Kuwaiti Dinar 0.413810 0.412698 0.411972 0.412242 Libyan Dinar 1.932400 1.932400 1.932400 1.932400 -Malaysian Ringgit 6.019640 6.040070 6.036680 6.007120 -Mauritian Rupee 48.187900 48.129000 47.930800 -Mexican Peso 27.710800 27.437600 -Nepalese Rupee 144.636000 145.108000 145.059000 144.616000 -New Zealand Dollar 1.884470 1.878650 1.871790 1.886670 -Norwegian Krone 11.290900 11.277300 11.277100 11.321500 -Rial Omani 0.519014 0.520950 0.520776 0.519041 -Pakistani Rupee 141.526000 142.035000 141.986000 141.501000 -Nuevo Sol 4.415560 -Philippine Peso 67.737800 67.642500 67.352800 -Polish Zloty 5.526540 5.513410 5.494510 5.501160 -Qatar Riyal 4.913430 4.931770 4.930120 4.913690 -Russian Ruble 78.100600 78.087200 77.406600 76.637200 -Saudi Arabian Riyal 5.061910 5.080810 5.079080 5.062190 -Singapore Dollar 1.917730 1.920410 1.922470 1.915930 -South African Rand 17.785300 17.766400 17.563400 17.586800 -Sri Lanka Rupee 203.995000 204.245000 204.168000 203.494000 -Swedish Krona 12.121600 12.038900 12.060600 12.071500 -Swiss Franc 1.362940 1.353930 1.355640 1.362200 -Thai Baht 47.305300 47.412700 47.402100 47.271300 -Trinidad And Tobago Dollar 9.128170 9.148130 9.140770 9.110290 -Tunisian Dinar 3.091930 3.096710 3.112600 3.087250 -U.A.E. Dirham 4.957290 4.975790 4.974130 4.957560 -Peso Uruguayo 38.323400 38.318700 -Bolivar Fuerte 13.510400 13.465400 +Malaysian Ringgit 6.024240 6.013450 6.012330 6.019640 +Mauritian Rupee 47.980500 +Mexican Peso 26.874000 26.622800 26.861400 27.602800 +Nepalese Rupee 144.901000 144.863000 144.447000 144.636000 +New Zealand Dollar 1.875660 1.878680 1.884020 1.884470 +Norwegian Krone 11.285900 11.256200 11.311200 11.290900 +Rial Omani 0.520988 0.519588 0.518675 0.519014 +Pakistani Rupee 142.077000 141.692000 141.442000 141.526000 +Nuevo Sol 4.378320 4.371990 4.382950 +Philippine Peso 68.063300 67.891000 67.859600 67.737800 +Polish Zloty 5.512190 5.518860 5.517120 5.526540 +Qatar Riyal 4.932130 4.918860 4.910220 4.913430 +Russian Ruble 77.533200 78.100600 +Saudi Arabian Riyal 5.081170 5.067500 5.058600 5.061910 +Singapore Dollar 1.903340 1.911870 1.913900 1.917730 +South African Rand 17.564000 17.516500 17.663900 17.785300 +Sri Lanka Rupee 204.369000 204.020000 203.995000 +Swedish Krona 12.157400 12.126500 12.142700 12.121600 +Swiss Franc 1.361350 1.364040 1.367580 1.362940 +Thai Baht 47.371400 47.288700 47.235100 47.305300 +Trinidad And Tobago Dollar 9.157260 9.163380 9.142270 9.128170 +Tunisian Dinar 3.118540 3.120570 3.100020 3.091930 +U.A.E. Dirham 4.976160 4.962780 4.954050 4.957290 +Peso Uruguayo 38.488800 38.298300 38.238400 +Bolivar Fuerte 13.515900 13.479600 (1) Exchange rates are published daily except on IMF holidays or whenever the IMF is closed for business. diff --git a/core-java/.resourceCache/IMFRateProvider.dat b/core-java/.resourceCache/IMFRateProvider.dat index 1db358b58b..4c98b3b04e 100644 --- a/core-java/.resourceCache/IMFRateProvider.dat +++ b/core-java/.resourceCache/IMFRateProvider.dat @@ -2,113 +2,113 @@ SDRs per Currency unit and Currency units per SDR (1) last five days SDRs per Currency unit (2) -Currency February 22, 2017 February 21, 2017 February 17, 2017 February 16, 2017 February 15, 2017 -Chinese Yuan 0.1077740000 0.1075920000 0.1074250000 0.1075990000 0.1078580000 -Euro 0.7806080000 0.7860480000 0.7864600000 0.7819020000 -Japanese Yen 0.0065267800 0.0065271000 0.0065062900 0.0064850300 0.0064793800 -U.K. Pound Sterling 0.9217470000 0.9201430000 0.9163910000 0.9224580000 0.9204290000 -U.S. Dollar 0.7413120000 0.7408260000 0.7380730000 0.7383210000 0.7407880000 -Algerian Dinar 0.0067122300 0.0067137500 0.0067192300 0.0067098500 -Australian Dollar 0.5680650000 0.5689800000 0.5694670000 0.5682580000 -Bahrain Dinar 1.9702800000 1.9629600000 1.9636200000 1.9701800000 -Botswana Pula 0.0708970000 0.0709288000 0.0712480000 0.0711156000 -Brazilian Real 0.2396560000 0.2419590000 0.2399250000 0.2389790000 -Brunei Dollar 0.5214510000 0.5207230000 0.5201640000 0.5219390000 -Canadian Dollar 0.5634090000 0.5627270000 0.5661790000 -Chilean Peso 0.0011535600 0.0011562200 0.0011537500 -Colombian Peso 0.0002552100 0.0002566600 0.0002567150 0.0002583270 -Czech Koruna 0.0288889000 0.0290901000 0.0291136000 -Danish Krone 0.1050150000 0.1057460000 0.1057900000 0.1051720000 -Hungarian Forint 0.0025387300 0.0025516800 0.0025498900 0.0025358200 -Icelandic Krona 0.0066885700 0.0066860500 0.0066725800 0.0066218600 -Indian Rupee 0.0110083000 0.0110285000 0.0110699000 -Indonesian Rupiah 0.0000554096 0.0000553776 0.0000553921 -Iranian Rial 0.0000228671 0.0000227947 0.0000228695 -Israeli New Sheqel 0.1998450000 0.1986200000 0.1986870000 0.1977020000 -Kazakhstani Tenge 0.0023350800 0.0023165400 0.0023114400 0.0023099100 -Korean Won 0.0006455440 0.0006480580 0.0006467420 0.0006472590 -Kuwaiti Dinar 2.4257600000 2.4171400000 2.4179500000 2.4248400000 +Currency February 27, 2017 February 24, 2017 February 23, 2017 February 22, 2017 February 21, 2017 +Chinese Yuan 0.1075530000 0.1074200000 0.1076250000 0.1077740000 0.1075920000 +Euro 0.7826360000 0.7829640000 0.7824120000 0.7793410000 0.7806080000 +Japanese Yen 0.0065915500 0.0065398200 0.0065279600 0.0065267800 0.0065271000 +U.K. Pound Sterling 0.9178430000 0.9263250000 0.9233090000 0.9217470000 0.9201430000 +U.S. Dollar 0.7392420000 0.7380190000 0.7400090000 0.7413120000 0.7408260000 +Algerian Dinar 0.0067056800 0.0067170500 0.0067108200 0.0067122300 +Australian Dollar 0.5695290000 0.5688450000 0.5701430000 0.5680650000 +Bahrain Dinar 1.9628200000 1.9681100000 1.9715700000 1.9702800000 +Botswana Pula 0.0712926000 0.0714849000 0.0710918000 0.0708970000 +Brazilian Real 0.2409310000 0.2401220000 0.2394110000 0.2396560000 +Brunei Dollar 0.5253930000 0.5230480000 0.5224920000 0.5214510000 +Canadian Dollar 0.5632010000 0.5645050000 0.5621540000 0.5634090000 +Chilean Peso 0.0011525100 0.0011535400 0.0011517700 0.0011535600 +Colombian Peso 0.0002570000 0.0002557440 0.0002553890 0.0002552100 +Czech Koruna 0.0289783000 0.0289564000 0.0288448000 0.0288889000 +Danish Krone 0.1053170000 0.1052550000 0.1048460000 0.1050150000 +Hungarian Forint 0.0025337100 0.0025343600 0.0025357900 0.0025387300 +Icelandic Krona 0.0068082900 0.0067593100 0.0067227000 0.0066885700 +Indian Rupee 0.0110722000 0.0110702000 +Indonesian Rupiah 0.0000553404 0.0000553899 0.0000555040 0.0000554096 +Iranian Rial 0.0000228786 0.0000228671 +Israeli New Sheqel 0.1995720000 0.1995710000 0.1998150000 0.1998450000 +Kazakhstani Tenge 0.0023693200 0.0023668900 0.0023601900 0.0023350800 +Korean Won 0.0006480670 0.0006486190 0.0006464180 0.0006455440 +Kuwaiti Dinar 2.4165700000 2.4230800000 2.4273500000 2.4257600000 Libyan Dinar 0.5174910000 0.5174910000 0.5174910000 0.5174910000 -Malaysian Ringgit 0.1661230000 0.1655610000 0.1656540000 0.1664690000 -Mauritian Rupee 0.0207521000 0.0207775000 0.0208634000 -Mexican Peso 0.0360870000 0.0364464000 -Nepalese Rupee 0.0069139200 0.0068914400 0.0068937500 0.0069148500 -New Zealand Dollar 0.5306540000 0.5322980000 0.5342490000 0.5300340000 -Norwegian Krone 0.0885668000 0.0886734000 0.0886755000 0.0883278000 -Rial Omani 1.9267300000 1.9195700000 1.9202100000 1.9266300000 -Pakistani Rupee 0.0070658600 0.0070405000 0.0070429300 0.0070671000 -Nuevo Sol 0.2264720000 -Philippine Peso 0.0147628000 0.0147836000 0.0148472000 -Polish Zloty 0.1809450000 0.1813760000 0.1820000000 0.1817800000 -Qatar Riyal 0.2035240000 0.2027670000 0.2028350000 0.2035130000 -Russian Ruble 0.0128040000 0.0128062000 0.0129188000 0.0130485000 -Saudi Arabian Riyal 0.1975540000 0.1968190000 0.1968860000 0.1975430000 -Singapore Dollar 0.5214510000 0.5207230000 0.5201640000 0.5219390000 -South African Rand 0.0562263000 0.0562860000 0.0569367000 0.0568608000 -Sri Lanka Rupee 0.0049020900 0.0048960700 0.0048979200 0.0049141600 -Swedish Krona 0.0824973000 0.0830639000 0.0829146000 0.0828400000 -Swiss Franc 0.7337090000 0.7385900000 0.7376570000 0.7341080000 -Thai Baht 0.0211393000 0.0210914000 0.0210961000 0.0211545000 -Trinidad And Tobago Dollar 0.1095510000 0.1093120000 0.1094000000 0.1097660000 -Tunisian Dinar 0.3234230000 0.3229230000 0.3212750000 0.3239130000 -U.A.E. Dirham 0.2017230000 0.2009730000 0.2010400000 0.2017120000 -Peso Uruguayo 0.0260937000 0.0260969000 -Bolivar Fuerte 0.0740171000 0.0742645000 +Malaysian Ringgit 0.1659960000 0.1662940000 0.1663250000 0.1661230000 +Mauritian Rupee 0.0208418000 +Mexican Peso 0.0372107000 0.0375618000 0.0372281000 0.0362282000 +Nepalese Rupee 0.0069012400 0.0069030700 0.0069229700 0.0069139200 +New Zealand Dollar 0.5331450000 0.5322880000 0.5307790000 0.5306540000 +Norwegian Krone 0.0886062000 0.0888398000 0.0884082000 0.0885668000 +Rial Omani 1.9194300000 1.9246000000 1.9279900000 1.9267300000 +Pakistani Rupee 0.0070384300 0.0070575400 0.0070700400 0.0070658600 +Nuevo Sol 0.2283980000 0.2287290000 0.2281570000 +Philippine Peso 0.0146922000 0.0147295000 0.0147363000 0.0147628000 +Polish Zloty 0.1814160000 0.1811970000 0.1812540000 0.1809450000 +Qatar Riyal 0.2027520000 0.2032990000 0.2036570000 0.2035240000 +Russian Ruble 0.0128977000 0.0128040000 +Saudi Arabian Riyal 0.1968050000 0.1973360000 0.1976830000 0.1975540000 +Singapore Dollar 0.5253930000 0.5230480000 0.5224920000 0.5214510000 +South African Rand 0.0569347000 0.0570889000 0.0566127000 0.0562263000 +Sri Lanka Rupee 0.0048931100 0.0049014800 0.0049020900 +Swedish Krona 0.0822544000 0.0824642000 0.0823543000 0.0824973000 +Swiss Franc 0.7345670000 0.7331180000 0.7312210000 0.7337090000 +Thai Baht 0.0211098000 0.0211467000 0.0211707000 0.0211393000 +Trinidad And Tobago Dollar 0.1092030000 0.1091300000 0.1093820000 0.1095510000 +Tunisian Dinar 0.3206630000 0.3204540000 0.3225790000 0.3234230000 +U.A.E. Dirham 0.2009580000 0.2015000000 0.2018550000 0.2017230000 +Peso Uruguayo 0.0259816000 0.0261108000 0.0261517000 +Bolivar Fuerte 0.0739869000 0.0741864000 Currency units per SDR(3) -Currency February 22, 2017 February 21, 2017 February 17, 2017 February 16, 2017 February 15, 2017 -Chinese Yuan 9.278680 9.294370 9.308820 9.293770 9.271450 -Euro 1.281050 1.272190 1.271520 1.278930 -Japanese Yen 153.215000 153.207000 153.697000 154.201000 154.336000 -U.K. Pound Sterling 1.084900 1.086790 1.091240 1.084060 1.086450 -U.S. Dollar 1.348960 1.349840 1.354880 1.354420 1.349910 -Algerian Dinar 148.982000 148.948000 148.827000 149.035000 -Australian Dollar 1.760360 1.757530 1.756030 1.759760 -Bahrain Dinar 0.507542 0.509435 0.509264 0.507568 -Botswana Pula 14.105000 14.098600 14.035500 14.061600 -Brazilian Real 4.172650 4.132930 4.167970 4.184470 -Brunei Dollar 1.917730 1.920410 1.922470 1.915930 -Canadian Dollar 1.774910 1.777060 1.766230 -Chilean Peso 866.882000 864.887000 866.739000 -Colombian Peso 3,918.340000 3,896.210000 3,895.370000 3,871.060000 -Czech Koruna 34.615400 34.376000 34.348200 -Danish Krone 9.522450 9.456620 9.452690 9.508230 -Hungarian Forint 393.898000 391.899000 392.174000 394.350000 -Icelandic Krona 149.509000 149.565000 149.867000 151.015000 -Indian Rupee 90.840500 90.674200 90.335100 -Indonesian Rupiah 18,047.400000 18,057.800000 18,053.100000 -Iranian Rial 43,730.900000 43,869.800000 43,726.400000 -Israeli New Sheqel 5.003880 5.034740 5.033040 5.058120 -Kazakhstani Tenge 428.251000 431.678000 432.631000 432.917000 -Korean Won 1,549.080000 1,543.070000 1,546.210000 1,544.980000 -Kuwaiti Dinar 0.412242 0.413712 0.413573 0.412398 +Currency February 27, 2017 February 24, 2017 February 23, 2017 February 22, 2017 February 21, 2017 +Chinese Yuan 9.297740 9.309250 9.291520 9.278680 9.294370 +Euro 1.277730 1.277200 1.278100 1.283140 1.281050 +Japanese Yen 151.709000 152.909000 153.187000 153.215000 153.207000 +U.K. Pound Sterling 1.089510 1.079530 1.083060 1.084900 1.086790 +U.S. Dollar 1.352740 1.354980 1.351330 1.348960 1.349840 +Algerian Dinar 149.127000 148.875000 149.013000 148.982000 +Australian Dollar 1.755840 1.757950 1.753950 1.760360 +Bahrain Dinar 0.509471 0.508102 0.507210 0.507542 +Botswana Pula 14.026700 13.989000 14.066300 14.105000 +Brazilian Real 4.150570 4.164550 4.176920 4.172650 +Brunei Dollar 1.903340 1.911870 1.913900 1.917730 +Canadian Dollar 1.775570 1.771460 1.778870 1.774910 +Chilean Peso 867.671000 866.897000 868.229000 866.882000 +Colombian Peso 3,891.050000 3,910.160000 3,915.600000 3,918.340000 +Czech Koruna 34.508600 34.534700 34.668300 34.615400 +Danish Krone 9.495140 9.500740 9.537800 9.522450 +Hungarian Forint 394.678000 394.577000 394.354000 393.898000 +Icelandic Krona 146.880000 147.944000 148.750000 149.509000 +Indian Rupee 90.316300 90.332600 +Indonesian Rupiah 18,070.000000 18,053.800000 18,016.700000 18,047.400000 +Iranian Rial 43,709.000000 43,730.900000 +Israeli New Sheqel 5.010720 5.010750 5.004630 5.003880 +Kazakhstani Tenge 422.062000 422.495000 423.695000 428.251000 +Korean Won 1,543.050000 1,541.740000 1,546.990000 1,549.080000 +Kuwaiti Dinar 0.413810 0.412698 0.411972 0.412242 Libyan Dinar 1.932400 1.932400 1.932400 1.932400 -Malaysian Ringgit 6.019640 6.040070 6.036680 6.007120 -Mauritian Rupee 48.187900 48.129000 47.930800 -Mexican Peso 27.710800 27.437600 -Nepalese Rupee 144.636000 145.108000 145.059000 144.616000 -New Zealand Dollar 1.884470 1.878650 1.871790 1.886670 -Norwegian Krone 11.290900 11.277300 11.277100 11.321500 -Rial Omani 0.519014 0.520950 0.520776 0.519041 -Pakistani Rupee 141.526000 142.035000 141.986000 141.501000 -Nuevo Sol 4.415560 -Philippine Peso 67.737800 67.642500 67.352800 -Polish Zloty 5.526540 5.513410 5.494510 5.501160 -Qatar Riyal 4.913430 4.931770 4.930120 4.913690 -Russian Ruble 78.100600 78.087200 77.406600 76.637200 -Saudi Arabian Riyal 5.061910 5.080810 5.079080 5.062190 -Singapore Dollar 1.917730 1.920410 1.922470 1.915930 -South African Rand 17.785300 17.766400 17.563400 17.586800 -Sri Lanka Rupee 203.995000 204.245000 204.168000 203.494000 -Swedish Krona 12.121600 12.038900 12.060600 12.071500 -Swiss Franc 1.362940 1.353930 1.355640 1.362200 -Thai Baht 47.305300 47.412700 47.402100 47.271300 -Trinidad And Tobago Dollar 9.128170 9.148130 9.140770 9.110290 -Tunisian Dinar 3.091930 3.096710 3.112600 3.087250 -U.A.E. Dirham 4.957290 4.975790 4.974130 4.957560 -Peso Uruguayo 38.323400 38.318700 -Bolivar Fuerte 13.510400 13.465400 +Malaysian Ringgit 6.024240 6.013450 6.012330 6.019640 +Mauritian Rupee 47.980500 +Mexican Peso 26.874000 26.622800 26.861400 27.602800 +Nepalese Rupee 144.901000 144.863000 144.447000 144.636000 +New Zealand Dollar 1.875660 1.878680 1.884020 1.884470 +Norwegian Krone 11.285900 11.256200 11.311200 11.290900 +Rial Omani 0.520988 0.519588 0.518675 0.519014 +Pakistani Rupee 142.077000 141.692000 141.442000 141.526000 +Nuevo Sol 4.378320 4.371990 4.382950 +Philippine Peso 68.063300 67.891000 67.859600 67.737800 +Polish Zloty 5.512190 5.518860 5.517120 5.526540 +Qatar Riyal 4.932130 4.918860 4.910220 4.913430 +Russian Ruble 77.533200 78.100600 +Saudi Arabian Riyal 5.081170 5.067500 5.058600 5.061910 +Singapore Dollar 1.903340 1.911870 1.913900 1.917730 +South African Rand 17.564000 17.516500 17.663900 17.785300 +Sri Lanka Rupee 204.369000 204.020000 203.995000 +Swedish Krona 12.157400 12.126500 12.142700 12.121600 +Swiss Franc 1.361350 1.364040 1.367580 1.362940 +Thai Baht 47.371400 47.288700 47.235100 47.305300 +Trinidad And Tobago Dollar 9.157260 9.163380 9.142270 9.128170 +Tunisian Dinar 3.118540 3.120570 3.100020 3.091930 +U.A.E. Dirham 4.976160 4.962780 4.954050 4.957290 +Peso Uruguayo 38.488800 38.298300 38.238400 +Bolivar Fuerte 13.515900 13.479600 (1) Exchange rates are published daily except on IMF holidays or whenever the IMF is closed for business. diff --git a/core-java/src/main/java/com/baeldung/money/JavaMoney.java b/core-java/src/main/java/com/baeldung/money/JavaMoney.java index f66480bea5..3171d226ed 100644 --- a/core-java/src/main/java/com/baeldung/money/JavaMoney.java +++ b/core-java/src/main/java/com/baeldung/money/JavaMoney.java @@ -81,7 +81,11 @@ public class JavaMoney { LOGGER.info("Money & FastMoney operations : " + calcMoneyFastMoney); - monetaryAmounts = new MonetaryAmount[] { Money.of(100, "CHF"), Money.of(10.20, "CHF"), Money.of(1.15, "CHF"), }; + monetaryAmounts = + new MonetaryAmount[] { + Money.of(100, "CHF"), + Money.of(10.20, "CHF"), + Money.of(1.15, "CHF"), }; sumAmtCHF = Money.of(0, "CHF"); for (MonetaryAmount monetaryAmount : monetaryAmounts) { sumAmtCHF = sumAmtCHF.add(monetaryAmount); @@ -134,7 +138,7 @@ public class JavaMoney { usFormatted = formatUSD.format(oneDolar); LOGGER.info("One dolar standard formatted : " + usFormatted); - customFormat = MonetaryFormats.getAmountFormat(AmountFormatQueryBuilder.of(Locale.US).set(CurrencyStyle.NAME).set("pattern", "00000.00 ค").build()); + customFormat = MonetaryFormats.getAmountFormat(AmountFormatQueryBuilder.of(Locale.US).set(CurrencyStyle.NAME).set("pattern", "00000.00 ยค").build()); customFormatted = customFormat.format(oneDolar); LOGGER.info("One dolar custom formatted : " + customFormatted); } diff --git a/core-java/src/test/java/com/baeldung/money/JavaMoneyTest.java b/core-java/src/test/java/com/baeldung/money/JavaMoneyTest.java index 25fcd48f7a..5aa12095ff 100644 --- a/core-java/src/test/java/com/baeldung/money/JavaMoneyTest.java +++ b/core-java/src/test/java/com/baeldung/money/JavaMoneyTest.java @@ -1,24 +1,24 @@ package com.baeldung.money; +import static org.junit.Assert.*; + import javax.money.convert.ConversionQueryBuilder; import javax.money.convert.MonetaryConversions; +import org.junit.Test; + import com.baeldung.money.JavaMoney; import junit.framework.TestCase; public class JavaMoneyTest - extends TestCase { - JavaMoney j9m; - public JavaMoneyTest( String testName ) - { - super( testName ); - j9m = new JavaMoney(); - } - public void testAmounts() + @Test + public void givenAmountsAreCorrect() { + JavaMoney j9m; + j9m = new JavaMoney(); assertEquals("USD", j9m.USD.toString()); assertEquals("USD 1", j9m.oneDolar.toString()); assertEquals("EUR 1", j9m.oneEuro.toString()); @@ -29,7 +29,10 @@ public class JavaMoneyTest } - public void testArithmetic(){ + @Test + public void givenArithmeticIsCorrect(){ + JavaMoney j9m; + j9m = new JavaMoney(); assertEquals("USD -199.5", j9m.calcAmtUSD.toString()); assertEquals("CHF 111.35", j9m.sumAmtCHF.toString()); assertEquals("USD 10", j9m.calcMoneyFastMoney.toString()); @@ -37,17 +40,25 @@ public class JavaMoneyTest assertEquals("USD 4", j9m.divideAmount.toString()); } - public void testRounding(){ + @Test + public void givenRoundingIsCorrect(){ + JavaMoney j9m; + j9m = new JavaMoney(); assertEquals("EUR 1.3", j9m.roundEUR.toString()); } - public void testFormatting(){ + @Test + public void givenFormatIsCorrect(){ + JavaMoney j9m; + j9m = new JavaMoney(); assertEquals("USD1.00", j9m.usFormatted); assertEquals("00001.00 US Dollar", j9m.customFormatted); } - public void testConversion(){ - + @Test + public void givenConversionIsNotNull(){ + JavaMoney j9m; + j9m = new JavaMoney(); assertNotNull(MonetaryConversions.getConversion(ConversionQueryBuilder.of().setTermCurrency("EUR").build())); assertNotNull(MonetaryConversions.getConversion(ConversionQueryBuilder.of().setTermCurrency("USD").build())); assertNotNull(j9m.convertedAmountEURtoUSD); From 1df0503b202f6615f0870bbfe843597ec9596519 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 2 Mar 2017 12:06:22 -0400 Subject: [PATCH 3/4] Java Money & Currency --- .../.resourceCache/ECBCurrentRateProvider.dat | 60 ++--- .../ECBHistoric90RateProvider.dat | 8 +- .../IMFHistoricRateProvider.dat | 204 ++++++++--------- core-java/.resourceCache/IMFRateProvider.dat | 204 ++++++++--------- .../com/baeldung/money/JavaMoneyTest.java | 208 +++++++++++++----- 5 files changed, 396 insertions(+), 288 deletions(-) diff --git a/core-java/.resourceCache/ECBCurrentRateProvider.dat b/core-java/.resourceCache/ECBCurrentRateProvider.dat index 45cf516ac8..69eed9a0d8 100644 --- a/core-java/.resourceCache/ECBCurrentRateProvider.dat +++ b/core-java/.resourceCache/ECBCurrentRateProvider.dat @@ -5,38 +5,38 @@ European Central Bank - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/core-java/.resourceCache/ECBHistoric90RateProvider.dat b/core-java/.resourceCache/ECBHistoric90RateProvider.dat index f51c2eacfa..157cac1a6a 100644 --- a/core-java/.resourceCache/ECBHistoric90RateProvider.dat +++ b/core-java/.resourceCache/ECBHistoric90RateProvider.dat @@ -1,4 +1,6 @@ -Reference ratesEuropean Central Bank +Reference ratesEuropean Central Bank + + @@ -58,6 +60,4 @@ - - - \ No newline at end of file + \ No newline at end of file diff --git a/core-java/.resourceCache/IMFHistoricRateProvider.dat b/core-java/.resourceCache/IMFHistoricRateProvider.dat index 4c98b3b04e..12809d35af 100644 --- a/core-java/.resourceCache/IMFHistoricRateProvider.dat +++ b/core-java/.resourceCache/IMFHistoricRateProvider.dat @@ -2,113 +2,113 @@ SDRs per Currency unit and Currency units per SDR (1) last five days SDRs per Currency unit (2) -Currency February 27, 2017 February 24, 2017 February 23, 2017 February 22, 2017 February 21, 2017 -Chinese Yuan 0.1075530000 0.1074200000 0.1076250000 0.1077740000 0.1075920000 -Euro 0.7826360000 0.7829640000 0.7824120000 0.7793410000 0.7806080000 -Japanese Yen 0.0065915500 0.0065398200 0.0065279600 0.0065267800 0.0065271000 -U.K. Pound Sterling 0.9178430000 0.9263250000 0.9233090000 0.9217470000 0.9201430000 -U.S. Dollar 0.7392420000 0.7380190000 0.7400090000 0.7413120000 0.7408260000 -Algerian Dinar 0.0067056800 0.0067170500 0.0067108200 0.0067122300 -Australian Dollar 0.5695290000 0.5688450000 0.5701430000 0.5680650000 -Bahrain Dinar 1.9628200000 1.9681100000 1.9715700000 1.9702800000 -Botswana Pula 0.0712926000 0.0714849000 0.0710918000 0.0708970000 -Brazilian Real 0.2409310000 0.2401220000 0.2394110000 0.2396560000 -Brunei Dollar 0.5253930000 0.5230480000 0.5224920000 0.5214510000 -Canadian Dollar 0.5632010000 0.5645050000 0.5621540000 0.5634090000 -Chilean Peso 0.0011525100 0.0011535400 0.0011517700 0.0011535600 -Colombian Peso 0.0002570000 0.0002557440 0.0002553890 0.0002552100 -Czech Koruna 0.0289783000 0.0289564000 0.0288448000 0.0288889000 -Danish Krone 0.1053170000 0.1052550000 0.1048460000 0.1050150000 -Hungarian Forint 0.0025337100 0.0025343600 0.0025357900 0.0025387300 -Icelandic Krona 0.0068082900 0.0067593100 0.0067227000 0.0066885700 -Indian Rupee 0.0110722000 0.0110702000 -Indonesian Rupiah 0.0000553404 0.0000553899 0.0000555040 0.0000554096 -Iranian Rial 0.0000228786 0.0000228671 -Israeli New Sheqel 0.1995720000 0.1995710000 0.1998150000 0.1998450000 -Kazakhstani Tenge 0.0023693200 0.0023668900 0.0023601900 0.0023350800 -Korean Won 0.0006480670 0.0006486190 0.0006464180 0.0006455440 -Kuwaiti Dinar 2.4165700000 2.4230800000 2.4273500000 2.4257600000 +Currency March 02, 2017 March 01, 2017 February 28, 2017 February 27, 2017 February 24, 2017 +Chinese Yuan 0.1078010000 0.1075250000 0.1075530000 0.1074200000 +Euro 0.7811130000 0.7827060000 0.7826360000 0.7829640000 +Japanese Yen 0.0065627100 0.0065625100 0.0065915500 0.0065398200 +U.K. Pound Sterling 0.9132630000 0.9188320000 0.9178430000 0.9263250000 +U.S. Dollar 0.7415860000 0.7386110000 0.7392420000 0.7380190000 +Algerian Dinar 0.0067127200 0.0067093100 0.0067141700 0.0067056800 +Australian Dollar 0.5677580000 0.5678440000 0.5688470000 0.5695290000 +Bahrain Dinar 1.9723000000 1.9643900000 1.9660700000 1.9628200000 +Botswana Pula 0.0711181000 0.0711282000 0.0712629000 0.0712926000 +Brazilian Real 0.2393220000 0.2383620000 0.2385650000 0.2409310000 +Brunei Dollar 0.5269940000 0.5260760000 0.5261880000 0.5253930000 +Canadian Dollar 0.5575260000 0.5642640000 0.5632010000 +Chilean Peso 0.0011428700 0.0011448000 0.0011449400 0.0011525100 +Colombian Peso 0.0002540400 0.0002550210 0.0002561010 0.0002570000 +Czech Koruna 0.0289072000 0.0289685000 0.0289649000 0.0289783000 +Danish Krone 0.1050820000 0.1052990000 0.1052900000 0.1053170000 +Hungarian Forint 0.0025403700 0.0025419400 0.0025407000 0.0025337100 +Icelandic Krona 0.0069632500 0.0069197200 0.0068709200 0.0068082900 +Indian Rupee 0.0110936000 0.0110674000 0.0110790000 +Indonesian Rupiah 0.0000555038 0.0000553391 0.0000554196 0.0000553404 +Iranian Rial 0.0000228835 0.0000227945 0.0000228133 +Israeli New Sheqel 0.2041810000 0.2018610000 0.2009360000 0.1995720000 +Kazakhstani Tenge 0.0023615900 0.0023658000 0.0023693200 +Korean Won 0.0006524260 0.0006536180 0.0006480670 +Kuwaiti Dinar 2.4274500000 2.4193000000 2.4213600000 2.4165700000 Libyan Dinar 0.5174910000 0.5174910000 0.5174910000 0.5174910000 -Malaysian Ringgit 0.1659960000 0.1662940000 0.1663250000 0.1661230000 -Mauritian Rupee 0.0208418000 -Mexican Peso 0.0372107000 0.0375618000 0.0372281000 0.0362282000 -Nepalese Rupee 0.0069012400 0.0069030700 0.0069229700 0.0069139200 -New Zealand Dollar 0.5331450000 0.5322880000 0.5307790000 0.5306540000 -Norwegian Krone 0.0886062000 0.0888398000 0.0884082000 0.0885668000 -Rial Omani 1.9194300000 1.9246000000 1.9279900000 1.9267300000 -Pakistani Rupee 0.0070384300 0.0070575400 0.0070700400 0.0070658600 -Nuevo Sol 0.2283980000 0.2287290000 0.2281570000 -Philippine Peso 0.0146922000 0.0147295000 0.0147363000 0.0147628000 -Polish Zloty 0.1814160000 0.1811970000 0.1812540000 0.1809450000 -Qatar Riyal 0.2027520000 0.2032990000 0.2036570000 0.2035240000 -Russian Ruble 0.0128977000 0.0128040000 -Saudi Arabian Riyal 0.1968050000 0.1973360000 0.1976830000 0.1975540000 -Singapore Dollar 0.5253930000 0.5230480000 0.5224920000 0.5214510000 -South African Rand 0.0569347000 0.0570889000 0.0566127000 0.0562263000 -Sri Lanka Rupee 0.0048931100 0.0049014800 0.0049020900 -Swedish Krona 0.0822544000 0.0824642000 0.0823543000 0.0824973000 -Swiss Franc 0.7345670000 0.7331180000 0.7312210000 0.7337090000 -Thai Baht 0.0211098000 0.0211467000 0.0211707000 0.0211393000 -Trinidad And Tobago Dollar 0.1092030000 0.1091300000 0.1093820000 0.1095510000 -Tunisian Dinar 0.3206630000 0.3204540000 0.3225790000 0.3234230000 -U.A.E. Dirham 0.2009580000 0.2015000000 0.2018550000 0.2017230000 -Peso Uruguayo 0.0259816000 0.0261108000 0.0261517000 -Bolivar Fuerte 0.0739869000 0.0741864000 +Malaysian Ringgit 0.1667420000 0.1661670000 0.1663840000 0.1659960000 +Mauritian Rupee 0.0208473000 0.0207651000 0.0207673000 +Mexican Peso 0.0369385000 0.0372748000 0.0372107000 +Nepalese Rupee 0.0069436900 0.0069210200 0.0069133300 0.0069012400 +New Zealand Dollar 0.5305310000 0.5304700000 0.5318850000 0.5331450000 +Norwegian Krone 0.0881434000 0.0882493000 0.0885500000 0.0886062000 +Rial Omani 1.9287000000 1.9209600000 1.9226100000 1.9194300000 +Pakistani Rupee 0.0070732900 0.0070443600 0.0070502500 0.0070384300 +Nuevo Sol 0.2266370000 0.2274590000 0.2271530000 +Philippine Peso 0.0147565000 0.0146938000 0.0147268000 0.0146922000 +Polish Zloty 0.1819580000 0.1811650000 0.1814310000 0.1814160000 +Qatar Riyal 0.2037320000 0.2029150000 0.2030880000 0.2027520000 +Russian Ruble 0.0127033000 0.0127429000 0.0127594000 +Saudi Arabian Riyal 0.1977560000 0.1969630000 0.1971310000 0.1968050000 +Singapore Dollar 0.5269940000 0.5260760000 0.5261880000 0.5253930000 +South African Rand 0.0567982000 0.0567078000 0.0569908000 0.0569347000 +Sri Lanka Rupee 0.0049030500 0.0048833800 0.0048875500 +Swedish Krona 0.0818510000 0.0817029000 0.0818978000 0.0822544000 +Swiss Franc 0.7340980000 0.7348630000 0.7341760000 0.7345670000 +Thai Baht 0.0211936000 0.0211661000 0.0212042000 0.0211098000 +Trinidad And Tobago Dollar 0.1102220000 0.1092030000 +Tunisian Dinar 0.3225800000 0.3211100000 0.3215340000 0.3206630000 +U.A.E. Dirham 0.2019290000 0.2011190000 0.2012910000 0.2009580000 +Peso Uruguayo 0.0258745000 +Bolivar Fuerte 0.0743445000 0.0740462000 0.0741095000 0.0739869000 Currency units per SDR(3) -Currency February 27, 2017 February 24, 2017 February 23, 2017 February 22, 2017 February 21, 2017 -Chinese Yuan 9.297740 9.309250 9.291520 9.278680 9.294370 -Euro 1.277730 1.277200 1.278100 1.283140 1.281050 -Japanese Yen 151.709000 152.909000 153.187000 153.215000 153.207000 -U.K. Pound Sterling 1.089510 1.079530 1.083060 1.084900 1.086790 -U.S. Dollar 1.352740 1.354980 1.351330 1.348960 1.349840 -Algerian Dinar 149.127000 148.875000 149.013000 148.982000 -Australian Dollar 1.755840 1.757950 1.753950 1.760360 -Bahrain Dinar 0.509471 0.508102 0.507210 0.507542 -Botswana Pula 14.026700 13.989000 14.066300 14.105000 -Brazilian Real 4.150570 4.164550 4.176920 4.172650 -Brunei Dollar 1.903340 1.911870 1.913900 1.917730 -Canadian Dollar 1.775570 1.771460 1.778870 1.774910 -Chilean Peso 867.671000 866.897000 868.229000 866.882000 -Colombian Peso 3,891.050000 3,910.160000 3,915.600000 3,918.340000 -Czech Koruna 34.508600 34.534700 34.668300 34.615400 -Danish Krone 9.495140 9.500740 9.537800 9.522450 -Hungarian Forint 394.678000 394.577000 394.354000 393.898000 -Icelandic Krona 146.880000 147.944000 148.750000 149.509000 -Indian Rupee 90.316300 90.332600 -Indonesian Rupiah 18,070.000000 18,053.800000 18,016.700000 18,047.400000 -Iranian Rial 43,709.000000 43,730.900000 -Israeli New Sheqel 5.010720 5.010750 5.004630 5.003880 -Kazakhstani Tenge 422.062000 422.495000 423.695000 428.251000 -Korean Won 1,543.050000 1,541.740000 1,546.990000 1,549.080000 -Kuwaiti Dinar 0.413810 0.412698 0.411972 0.412242 +Currency March 02, 2017 March 01, 2017 February 28, 2017 February 27, 2017 February 24, 2017 +Chinese Yuan 9.276350 9.300160 9.297740 9.309250 +Euro 1.280220 1.277620 1.277730 1.277200 +Japanese Yen 152.376000 152.381000 151.709000 152.909000 +U.K. Pound Sterling 1.094970 1.088340 1.089510 1.079530 +U.S. Dollar 1.348460 1.353890 1.352740 1.354980 +Algerian Dinar 148.971000 149.047000 148.939000 149.127000 +Australian Dollar 1.761310 1.761050 1.757940 1.755840 +Bahrain Dinar 0.507022 0.509064 0.508629 0.509471 +Botswana Pula 14.061100 14.059100 14.032500 14.026700 +Brazilian Real 4.178470 4.195300 4.191730 4.150570 +Brunei Dollar 1.897550 1.900870 1.900460 1.903340 +Canadian Dollar 1.793640 1.772220 1.775570 +Chilean Peso 874.990000 873.515000 873.408000 867.671000 +Colombian Peso 3,936.390000 3,921.250000 3,904.710000 3,891.050000 +Czech Koruna 34.593500 34.520300 34.524500 34.508600 +Danish Krone 9.516380 9.496770 9.497580 9.495140 +Hungarian Forint 393.643000 393.400000 393.592000 394.678000 +Icelandic Krona 143.611000 144.515000 145.541000 146.880000 +Indian Rupee 90.142100 90.355500 90.260900 +Indonesian Rupiah 18,016.800000 18,070.400000 18,044.200000 18,070.000000 +Iranian Rial 43,699.600000 43,870.200000 43,834.100000 +Israeli New Sheqel 4.897620 4.953900 4.976710 5.010720 +Kazakhstani Tenge 423.444000 422.690000 422.062000 +Korean Won 1,532.740000 1,529.950000 1,543.050000 +Kuwaiti Dinar 0.411955 0.413343 0.412991 0.413810 Libyan Dinar 1.932400 1.932400 1.932400 1.932400 -Malaysian Ringgit 6.024240 6.013450 6.012330 6.019640 -Mauritian Rupee 47.980500 -Mexican Peso 26.874000 26.622800 26.861400 27.602800 -Nepalese Rupee 144.901000 144.863000 144.447000 144.636000 -New Zealand Dollar 1.875660 1.878680 1.884020 1.884470 -Norwegian Krone 11.285900 11.256200 11.311200 11.290900 -Rial Omani 0.520988 0.519588 0.518675 0.519014 -Pakistani Rupee 142.077000 141.692000 141.442000 141.526000 -Nuevo Sol 4.378320 4.371990 4.382950 -Philippine Peso 68.063300 67.891000 67.859600 67.737800 -Polish Zloty 5.512190 5.518860 5.517120 5.526540 -Qatar Riyal 4.932130 4.918860 4.910220 4.913430 -Russian Ruble 77.533200 78.100600 -Saudi Arabian Riyal 5.081170 5.067500 5.058600 5.061910 -Singapore Dollar 1.903340 1.911870 1.913900 1.917730 -South African Rand 17.564000 17.516500 17.663900 17.785300 -Sri Lanka Rupee 204.369000 204.020000 203.995000 -Swedish Krona 12.157400 12.126500 12.142700 12.121600 -Swiss Franc 1.361350 1.364040 1.367580 1.362940 -Thai Baht 47.371400 47.288700 47.235100 47.305300 -Trinidad And Tobago Dollar 9.157260 9.163380 9.142270 9.128170 -Tunisian Dinar 3.118540 3.120570 3.100020 3.091930 -U.A.E. Dirham 4.976160 4.962780 4.954050 4.957290 -Peso Uruguayo 38.488800 38.298300 38.238400 -Bolivar Fuerte 13.515900 13.479600 +Malaysian Ringgit 5.997290 6.018040 6.010190 6.024240 +Mauritian Rupee 47.967800 48.157700 48.152600 +Mexican Peso 27.072000 26.827800 26.874000 +Nepalese Rupee 144.016000 144.487000 144.648000 144.901000 +New Zealand Dollar 1.884900 1.885120 1.880110 1.875660 +Norwegian Krone 11.345100 11.331500 11.293100 11.285900 +Rial Omani 0.518484 0.520573 0.520126 0.520988 +Pakistani Rupee 141.377000 141.958000 141.839000 142.077000 +Nuevo Sol 4.412340 4.396400 4.402320 +Philippine Peso 67.766700 68.055900 67.903400 68.063300 +Polish Zloty 5.495770 5.519830 5.511740 5.512190 +Qatar Riyal 4.908410 4.928170 4.923970 4.932130 +Russian Ruble 78.719700 78.475100 78.373600 +Saudi Arabian Riyal 5.056740 5.077100 5.072770 5.081170 +Singapore Dollar 1.897550 1.900870 1.900460 1.903340 +South African Rand 17.606200 17.634300 17.546700 17.564000 +Sri Lanka Rupee 203.955000 204.776000 204.601000 +Swedish Krona 12.217300 12.239500 12.210300 12.157400 +Swiss Franc 1.362220 1.360800 1.362070 1.361350 +Thai Baht 47.184100 47.245400 47.160500 47.371400 +Trinidad And Tobago Dollar 9.072600 9.157260 +Tunisian Dinar 3.100010 3.114200 3.110090 3.118540 +U.A.E. Dirham 4.952240 4.972180 4.967930 4.976160 +Peso Uruguayo 38.648100 +Bolivar Fuerte 13.450900 13.505100 13.493500 13.515900 (1) Exchange rates are published daily except on IMF holidays or whenever the IMF is closed for business. diff --git a/core-java/.resourceCache/IMFRateProvider.dat b/core-java/.resourceCache/IMFRateProvider.dat index 4c98b3b04e..12809d35af 100644 --- a/core-java/.resourceCache/IMFRateProvider.dat +++ b/core-java/.resourceCache/IMFRateProvider.dat @@ -2,113 +2,113 @@ SDRs per Currency unit and Currency units per SDR (1) last five days SDRs per Currency unit (2) -Currency February 27, 2017 February 24, 2017 February 23, 2017 February 22, 2017 February 21, 2017 -Chinese Yuan 0.1075530000 0.1074200000 0.1076250000 0.1077740000 0.1075920000 -Euro 0.7826360000 0.7829640000 0.7824120000 0.7793410000 0.7806080000 -Japanese Yen 0.0065915500 0.0065398200 0.0065279600 0.0065267800 0.0065271000 -U.K. Pound Sterling 0.9178430000 0.9263250000 0.9233090000 0.9217470000 0.9201430000 -U.S. Dollar 0.7392420000 0.7380190000 0.7400090000 0.7413120000 0.7408260000 -Algerian Dinar 0.0067056800 0.0067170500 0.0067108200 0.0067122300 -Australian Dollar 0.5695290000 0.5688450000 0.5701430000 0.5680650000 -Bahrain Dinar 1.9628200000 1.9681100000 1.9715700000 1.9702800000 -Botswana Pula 0.0712926000 0.0714849000 0.0710918000 0.0708970000 -Brazilian Real 0.2409310000 0.2401220000 0.2394110000 0.2396560000 -Brunei Dollar 0.5253930000 0.5230480000 0.5224920000 0.5214510000 -Canadian Dollar 0.5632010000 0.5645050000 0.5621540000 0.5634090000 -Chilean Peso 0.0011525100 0.0011535400 0.0011517700 0.0011535600 -Colombian Peso 0.0002570000 0.0002557440 0.0002553890 0.0002552100 -Czech Koruna 0.0289783000 0.0289564000 0.0288448000 0.0288889000 -Danish Krone 0.1053170000 0.1052550000 0.1048460000 0.1050150000 -Hungarian Forint 0.0025337100 0.0025343600 0.0025357900 0.0025387300 -Icelandic Krona 0.0068082900 0.0067593100 0.0067227000 0.0066885700 -Indian Rupee 0.0110722000 0.0110702000 -Indonesian Rupiah 0.0000553404 0.0000553899 0.0000555040 0.0000554096 -Iranian Rial 0.0000228786 0.0000228671 -Israeli New Sheqel 0.1995720000 0.1995710000 0.1998150000 0.1998450000 -Kazakhstani Tenge 0.0023693200 0.0023668900 0.0023601900 0.0023350800 -Korean Won 0.0006480670 0.0006486190 0.0006464180 0.0006455440 -Kuwaiti Dinar 2.4165700000 2.4230800000 2.4273500000 2.4257600000 +Currency March 02, 2017 March 01, 2017 February 28, 2017 February 27, 2017 February 24, 2017 +Chinese Yuan 0.1078010000 0.1075250000 0.1075530000 0.1074200000 +Euro 0.7811130000 0.7827060000 0.7826360000 0.7829640000 +Japanese Yen 0.0065627100 0.0065625100 0.0065915500 0.0065398200 +U.K. Pound Sterling 0.9132630000 0.9188320000 0.9178430000 0.9263250000 +U.S. Dollar 0.7415860000 0.7386110000 0.7392420000 0.7380190000 +Algerian Dinar 0.0067127200 0.0067093100 0.0067141700 0.0067056800 +Australian Dollar 0.5677580000 0.5678440000 0.5688470000 0.5695290000 +Bahrain Dinar 1.9723000000 1.9643900000 1.9660700000 1.9628200000 +Botswana Pula 0.0711181000 0.0711282000 0.0712629000 0.0712926000 +Brazilian Real 0.2393220000 0.2383620000 0.2385650000 0.2409310000 +Brunei Dollar 0.5269940000 0.5260760000 0.5261880000 0.5253930000 +Canadian Dollar 0.5575260000 0.5642640000 0.5632010000 +Chilean Peso 0.0011428700 0.0011448000 0.0011449400 0.0011525100 +Colombian Peso 0.0002540400 0.0002550210 0.0002561010 0.0002570000 +Czech Koruna 0.0289072000 0.0289685000 0.0289649000 0.0289783000 +Danish Krone 0.1050820000 0.1052990000 0.1052900000 0.1053170000 +Hungarian Forint 0.0025403700 0.0025419400 0.0025407000 0.0025337100 +Icelandic Krona 0.0069632500 0.0069197200 0.0068709200 0.0068082900 +Indian Rupee 0.0110936000 0.0110674000 0.0110790000 +Indonesian Rupiah 0.0000555038 0.0000553391 0.0000554196 0.0000553404 +Iranian Rial 0.0000228835 0.0000227945 0.0000228133 +Israeli New Sheqel 0.2041810000 0.2018610000 0.2009360000 0.1995720000 +Kazakhstani Tenge 0.0023615900 0.0023658000 0.0023693200 +Korean Won 0.0006524260 0.0006536180 0.0006480670 +Kuwaiti Dinar 2.4274500000 2.4193000000 2.4213600000 2.4165700000 Libyan Dinar 0.5174910000 0.5174910000 0.5174910000 0.5174910000 -Malaysian Ringgit 0.1659960000 0.1662940000 0.1663250000 0.1661230000 -Mauritian Rupee 0.0208418000 -Mexican Peso 0.0372107000 0.0375618000 0.0372281000 0.0362282000 -Nepalese Rupee 0.0069012400 0.0069030700 0.0069229700 0.0069139200 -New Zealand Dollar 0.5331450000 0.5322880000 0.5307790000 0.5306540000 -Norwegian Krone 0.0886062000 0.0888398000 0.0884082000 0.0885668000 -Rial Omani 1.9194300000 1.9246000000 1.9279900000 1.9267300000 -Pakistani Rupee 0.0070384300 0.0070575400 0.0070700400 0.0070658600 -Nuevo Sol 0.2283980000 0.2287290000 0.2281570000 -Philippine Peso 0.0146922000 0.0147295000 0.0147363000 0.0147628000 -Polish Zloty 0.1814160000 0.1811970000 0.1812540000 0.1809450000 -Qatar Riyal 0.2027520000 0.2032990000 0.2036570000 0.2035240000 -Russian Ruble 0.0128977000 0.0128040000 -Saudi Arabian Riyal 0.1968050000 0.1973360000 0.1976830000 0.1975540000 -Singapore Dollar 0.5253930000 0.5230480000 0.5224920000 0.5214510000 -South African Rand 0.0569347000 0.0570889000 0.0566127000 0.0562263000 -Sri Lanka Rupee 0.0048931100 0.0049014800 0.0049020900 -Swedish Krona 0.0822544000 0.0824642000 0.0823543000 0.0824973000 -Swiss Franc 0.7345670000 0.7331180000 0.7312210000 0.7337090000 -Thai Baht 0.0211098000 0.0211467000 0.0211707000 0.0211393000 -Trinidad And Tobago Dollar 0.1092030000 0.1091300000 0.1093820000 0.1095510000 -Tunisian Dinar 0.3206630000 0.3204540000 0.3225790000 0.3234230000 -U.A.E. Dirham 0.2009580000 0.2015000000 0.2018550000 0.2017230000 -Peso Uruguayo 0.0259816000 0.0261108000 0.0261517000 -Bolivar Fuerte 0.0739869000 0.0741864000 +Malaysian Ringgit 0.1667420000 0.1661670000 0.1663840000 0.1659960000 +Mauritian Rupee 0.0208473000 0.0207651000 0.0207673000 +Mexican Peso 0.0369385000 0.0372748000 0.0372107000 +Nepalese Rupee 0.0069436900 0.0069210200 0.0069133300 0.0069012400 +New Zealand Dollar 0.5305310000 0.5304700000 0.5318850000 0.5331450000 +Norwegian Krone 0.0881434000 0.0882493000 0.0885500000 0.0886062000 +Rial Omani 1.9287000000 1.9209600000 1.9226100000 1.9194300000 +Pakistani Rupee 0.0070732900 0.0070443600 0.0070502500 0.0070384300 +Nuevo Sol 0.2266370000 0.2274590000 0.2271530000 +Philippine Peso 0.0147565000 0.0146938000 0.0147268000 0.0146922000 +Polish Zloty 0.1819580000 0.1811650000 0.1814310000 0.1814160000 +Qatar Riyal 0.2037320000 0.2029150000 0.2030880000 0.2027520000 +Russian Ruble 0.0127033000 0.0127429000 0.0127594000 +Saudi Arabian Riyal 0.1977560000 0.1969630000 0.1971310000 0.1968050000 +Singapore Dollar 0.5269940000 0.5260760000 0.5261880000 0.5253930000 +South African Rand 0.0567982000 0.0567078000 0.0569908000 0.0569347000 +Sri Lanka Rupee 0.0049030500 0.0048833800 0.0048875500 +Swedish Krona 0.0818510000 0.0817029000 0.0818978000 0.0822544000 +Swiss Franc 0.7340980000 0.7348630000 0.7341760000 0.7345670000 +Thai Baht 0.0211936000 0.0211661000 0.0212042000 0.0211098000 +Trinidad And Tobago Dollar 0.1102220000 0.1092030000 +Tunisian Dinar 0.3225800000 0.3211100000 0.3215340000 0.3206630000 +U.A.E. Dirham 0.2019290000 0.2011190000 0.2012910000 0.2009580000 +Peso Uruguayo 0.0258745000 +Bolivar Fuerte 0.0743445000 0.0740462000 0.0741095000 0.0739869000 Currency units per SDR(3) -Currency February 27, 2017 February 24, 2017 February 23, 2017 February 22, 2017 February 21, 2017 -Chinese Yuan 9.297740 9.309250 9.291520 9.278680 9.294370 -Euro 1.277730 1.277200 1.278100 1.283140 1.281050 -Japanese Yen 151.709000 152.909000 153.187000 153.215000 153.207000 -U.K. Pound Sterling 1.089510 1.079530 1.083060 1.084900 1.086790 -U.S. Dollar 1.352740 1.354980 1.351330 1.348960 1.349840 -Algerian Dinar 149.127000 148.875000 149.013000 148.982000 -Australian Dollar 1.755840 1.757950 1.753950 1.760360 -Bahrain Dinar 0.509471 0.508102 0.507210 0.507542 -Botswana Pula 14.026700 13.989000 14.066300 14.105000 -Brazilian Real 4.150570 4.164550 4.176920 4.172650 -Brunei Dollar 1.903340 1.911870 1.913900 1.917730 -Canadian Dollar 1.775570 1.771460 1.778870 1.774910 -Chilean Peso 867.671000 866.897000 868.229000 866.882000 -Colombian Peso 3,891.050000 3,910.160000 3,915.600000 3,918.340000 -Czech Koruna 34.508600 34.534700 34.668300 34.615400 -Danish Krone 9.495140 9.500740 9.537800 9.522450 -Hungarian Forint 394.678000 394.577000 394.354000 393.898000 -Icelandic Krona 146.880000 147.944000 148.750000 149.509000 -Indian Rupee 90.316300 90.332600 -Indonesian Rupiah 18,070.000000 18,053.800000 18,016.700000 18,047.400000 -Iranian Rial 43,709.000000 43,730.900000 -Israeli New Sheqel 5.010720 5.010750 5.004630 5.003880 -Kazakhstani Tenge 422.062000 422.495000 423.695000 428.251000 -Korean Won 1,543.050000 1,541.740000 1,546.990000 1,549.080000 -Kuwaiti Dinar 0.413810 0.412698 0.411972 0.412242 +Currency March 02, 2017 March 01, 2017 February 28, 2017 February 27, 2017 February 24, 2017 +Chinese Yuan 9.276350 9.300160 9.297740 9.309250 +Euro 1.280220 1.277620 1.277730 1.277200 +Japanese Yen 152.376000 152.381000 151.709000 152.909000 +U.K. Pound Sterling 1.094970 1.088340 1.089510 1.079530 +U.S. Dollar 1.348460 1.353890 1.352740 1.354980 +Algerian Dinar 148.971000 149.047000 148.939000 149.127000 +Australian Dollar 1.761310 1.761050 1.757940 1.755840 +Bahrain Dinar 0.507022 0.509064 0.508629 0.509471 +Botswana Pula 14.061100 14.059100 14.032500 14.026700 +Brazilian Real 4.178470 4.195300 4.191730 4.150570 +Brunei Dollar 1.897550 1.900870 1.900460 1.903340 +Canadian Dollar 1.793640 1.772220 1.775570 +Chilean Peso 874.990000 873.515000 873.408000 867.671000 +Colombian Peso 3,936.390000 3,921.250000 3,904.710000 3,891.050000 +Czech Koruna 34.593500 34.520300 34.524500 34.508600 +Danish Krone 9.516380 9.496770 9.497580 9.495140 +Hungarian Forint 393.643000 393.400000 393.592000 394.678000 +Icelandic Krona 143.611000 144.515000 145.541000 146.880000 +Indian Rupee 90.142100 90.355500 90.260900 +Indonesian Rupiah 18,016.800000 18,070.400000 18,044.200000 18,070.000000 +Iranian Rial 43,699.600000 43,870.200000 43,834.100000 +Israeli New Sheqel 4.897620 4.953900 4.976710 5.010720 +Kazakhstani Tenge 423.444000 422.690000 422.062000 +Korean Won 1,532.740000 1,529.950000 1,543.050000 +Kuwaiti Dinar 0.411955 0.413343 0.412991 0.413810 Libyan Dinar 1.932400 1.932400 1.932400 1.932400 -Malaysian Ringgit 6.024240 6.013450 6.012330 6.019640 -Mauritian Rupee 47.980500 -Mexican Peso 26.874000 26.622800 26.861400 27.602800 -Nepalese Rupee 144.901000 144.863000 144.447000 144.636000 -New Zealand Dollar 1.875660 1.878680 1.884020 1.884470 -Norwegian Krone 11.285900 11.256200 11.311200 11.290900 -Rial Omani 0.520988 0.519588 0.518675 0.519014 -Pakistani Rupee 142.077000 141.692000 141.442000 141.526000 -Nuevo Sol 4.378320 4.371990 4.382950 -Philippine Peso 68.063300 67.891000 67.859600 67.737800 -Polish Zloty 5.512190 5.518860 5.517120 5.526540 -Qatar Riyal 4.932130 4.918860 4.910220 4.913430 -Russian Ruble 77.533200 78.100600 -Saudi Arabian Riyal 5.081170 5.067500 5.058600 5.061910 -Singapore Dollar 1.903340 1.911870 1.913900 1.917730 -South African Rand 17.564000 17.516500 17.663900 17.785300 -Sri Lanka Rupee 204.369000 204.020000 203.995000 -Swedish Krona 12.157400 12.126500 12.142700 12.121600 -Swiss Franc 1.361350 1.364040 1.367580 1.362940 -Thai Baht 47.371400 47.288700 47.235100 47.305300 -Trinidad And Tobago Dollar 9.157260 9.163380 9.142270 9.128170 -Tunisian Dinar 3.118540 3.120570 3.100020 3.091930 -U.A.E. Dirham 4.976160 4.962780 4.954050 4.957290 -Peso Uruguayo 38.488800 38.298300 38.238400 -Bolivar Fuerte 13.515900 13.479600 +Malaysian Ringgit 5.997290 6.018040 6.010190 6.024240 +Mauritian Rupee 47.967800 48.157700 48.152600 +Mexican Peso 27.072000 26.827800 26.874000 +Nepalese Rupee 144.016000 144.487000 144.648000 144.901000 +New Zealand Dollar 1.884900 1.885120 1.880110 1.875660 +Norwegian Krone 11.345100 11.331500 11.293100 11.285900 +Rial Omani 0.518484 0.520573 0.520126 0.520988 +Pakistani Rupee 141.377000 141.958000 141.839000 142.077000 +Nuevo Sol 4.412340 4.396400 4.402320 +Philippine Peso 67.766700 68.055900 67.903400 68.063300 +Polish Zloty 5.495770 5.519830 5.511740 5.512190 +Qatar Riyal 4.908410 4.928170 4.923970 4.932130 +Russian Ruble 78.719700 78.475100 78.373600 +Saudi Arabian Riyal 5.056740 5.077100 5.072770 5.081170 +Singapore Dollar 1.897550 1.900870 1.900460 1.903340 +South African Rand 17.606200 17.634300 17.546700 17.564000 +Sri Lanka Rupee 203.955000 204.776000 204.601000 +Swedish Krona 12.217300 12.239500 12.210300 12.157400 +Swiss Franc 1.362220 1.360800 1.362070 1.361350 +Thai Baht 47.184100 47.245400 47.160500 47.371400 +Trinidad And Tobago Dollar 9.072600 9.157260 +Tunisian Dinar 3.100010 3.114200 3.110090 3.118540 +U.A.E. Dirham 4.952240 4.972180 4.967930 4.976160 +Peso Uruguayo 38.648100 +Bolivar Fuerte 13.450900 13.505100 13.493500 13.515900 (1) Exchange rates are published daily except on IMF holidays or whenever the IMF is closed for business. diff --git a/core-java/src/test/java/com/baeldung/money/JavaMoneyTest.java b/core-java/src/test/java/com/baeldung/money/JavaMoneyTest.java index 5aa12095ff..ed737c6184 100644 --- a/core-java/src/test/java/com/baeldung/money/JavaMoneyTest.java +++ b/core-java/src/test/java/com/baeldung/money/JavaMoneyTest.java @@ -1,69 +1,177 @@ package com.baeldung.money; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import java.math.BigDecimal; +import java.util.Locale; + +import javax.money.CurrencyUnit; +import javax.money.Monetary; +import javax.money.MonetaryAmount; +import javax.money.UnknownCurrencyException; import javax.money.convert.ConversionQueryBuilder; +import javax.money.convert.CurrencyConversion; import javax.money.convert.MonetaryConversions; +import javax.money.format.AmountFormatQueryBuilder; +import javax.money.format.MonetaryAmountFormat; +import javax.money.format.MonetaryFormats; +import org.javamoney.moneta.FastMoney; +import org.javamoney.moneta.Money; +import org.javamoney.moneta.format.CurrencyStyle; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.ExpectedException; -import com.baeldung.money.JavaMoney; - -import junit.framework.TestCase; - -public class JavaMoneyTest -{ +public class JavaMoneyTest { + @Rule + public ExpectedException thrown = ExpectedException.none(); @Test - public void givenAmountsAreCorrect() - { - JavaMoney j9m; - j9m = new JavaMoney(); - assertEquals("USD", j9m.USD.toString()); - assertEquals("USD 1", j9m.oneDolar.toString()); - assertEquals("EUR 1", j9m.oneEuro.toString()); - assertEquals("USD 200.5", j9m.fstAmtUSD.toString()); - assertEquals("EUR 1.30473908", j9m.fstAmtEUR.toString()); - assertEquals("USD 12", j9m.moneyof.toString()); - assertEquals("USD 2.00000", j9m.fastmoneyof.toString()); + public void givenCurrencyCode_whenString_thanExist() { + CurrencyUnit USD = Monetary.getCurrency("USD"); + assertNotNull(USD); + assertEquals(USD.getCurrencyCode(), "USD"); + assertEquals(USD.getNumericCode(), 840); + assertEquals(USD.getDefaultFractionDigits(), 2); + assertFalse(Monetary.isCurrencyAvailable("AAA")); + + } + + @Test + public void givenCurrencyCode_whenNoExist_thanThrowsError() { + thrown.expect(UnknownCurrencyException.class); + CurrencyUnit AAA = Monetary.getCurrency("AAA"); + assertNull(AAA); + throw new UnknownCurrencyException("AAA"); + } + + @Test + public void givenAmounts_whenStrinfied_thanEquals() { + CurrencyUnit USD = Monetary.getCurrency("USD"); + MonetaryAmount fstAmtUSD = Monetary.getDefaultAmountFactory().setCurrency(USD).setNumber(200.50).create(); + MonetaryAmount fstAmtEUR = Monetary.getDefaultAmountFactory().setCurrency("EUR").setNumber(1.30473908).create(); + MonetaryAmount oneDolar = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(1).create(); + Money moneyof = Money.of(12, USD); + FastMoney fastmoneyof = FastMoney.of(2, USD); + Money oneEuro = Money.of(1, "EUR"); + + assertEquals("USD", USD.toString()); + assertEquals("USD 1", oneDolar.toString()); + assertEquals("EUR 1", oneEuro.toString()); + assertEquals("USD 200.5", fstAmtUSD.toString()); + assertEquals("EUR 1.30473908", fstAmtEUR.toString()); + assertEquals("USD 12", moneyof.toString()); + assertEquals("USD 2.00000", fastmoneyof.toString()); + + } + + @Test + public void givenCurrencies_whenCompared_thanNotequal() { + MonetaryAmount oneDolar = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(1).create(); + Money oneEuro = Money.of(1, "EUR"); + assertFalse(oneEuro.equals(FastMoney.of(1, "EUR"))); + assertTrue(oneDolar.equals(Money.of(1, "USD"))); + + } + + @Test + public void givenAmount_whenDivided_thanThrowsException() { + MonetaryAmount oneDolar = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(1).create(); + thrown.expect(ArithmeticException.class); + MonetaryAmount oneDivThree = oneDolar.divide(3); + assertNull(oneDivThree); + throw new ArithmeticException(); + + } + + @Test + public void givenArithmetic_whenStrinfied_thanEqualsAmount() { + CurrencyUnit USD = Monetary.getCurrency("USD"); + Money moneyof = Money.of(12, USD); + MonetaryAmount fstAmtUSD = Monetary.getDefaultAmountFactory().setCurrency(USD).setNumber(200.50).create(); + Money calcAmtUSD = Money.of(1, "USD").subtract(fstAmtUSD); + FastMoney fastmoneyof = FastMoney.of(2, USD); + MonetaryAmount calcMoneyFastMoney = moneyof.subtract(fastmoneyof); + MonetaryAmount oneDolar = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(1).create(); + MonetaryAmount multiplyAmount = oneDolar.multiply(0.25); + MonetaryAmount divideAmount = oneDolar.divide(0.25); + MonetaryAmount[] monetaryAmounts = new MonetaryAmount[] { + Money.of(100, "CHF"), + Money.of(10.20, "CHF"), + Money.of(1.15, "CHF"), }; + + Money sumAmtCHF = Money.of(0, "CHF"); + + for (MonetaryAmount monetaryAmount : monetaryAmounts) { + sumAmtCHF = sumAmtCHF.add(monetaryAmount); + } + assertEquals("USD", USD.toString()); + assertEquals("USD 1", oneDolar.toString()); + assertEquals("USD 200.5", fstAmtUSD.toString()); + assertEquals("USD 12", moneyof.toString()); + assertEquals("USD 2.00000", fastmoneyof.toString()); + assertEquals("USD -199.5", calcAmtUSD.toString()); + assertEquals("CHF 111.35", sumAmtCHF.toString()); + assertEquals("USD 10", calcMoneyFastMoney.toString()); + assertEquals("USD 0.25", multiplyAmount.toString()); + assertEquals("USD 4", divideAmount.toString()); } - + @Test - public void givenArithmeticIsCorrect(){ - JavaMoney j9m; - j9m = new JavaMoney(); - assertEquals("USD -199.5", j9m.calcAmtUSD.toString()); - assertEquals("CHF 111.35", j9m.sumAmtCHF.toString()); - assertEquals("USD 10", j9m.calcMoneyFastMoney.toString()); - assertEquals("USD 0.25", j9m.multiplyAmount.toString()); - assertEquals("USD 4", j9m.divideAmount.toString()); + public void givenAmount_whenRounded_thanEquals() { + MonetaryAmount fstAmtEUR = Monetary.getDefaultAmountFactory().setCurrency("EUR").setNumber(1.30473908).create(); + MonetaryAmount roundEUR = fstAmtEUR.with(Monetary.getDefaultRounding()); + assertEquals("EUR 1.30473908", fstAmtEUR.toString()); + assertEquals("EUR 1.3", roundEUR.toString()); } - + @Test - public void givenRoundingIsCorrect(){ - JavaMoney j9m; - j9m = new JavaMoney(); - assertEquals("EUR 1.3", j9m.roundEUR.toString()); + public void givenAmount_whenCustomFormat_thanEquals() { + MonetaryAmount oneDolar = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(1).create(); + MonetaryAmountFormat formatUSD = MonetaryFormats.getAmountFormat(Locale.US); + String usFormatted = formatUSD.format(oneDolar); + + MonetaryAmountFormat customFormat = MonetaryFormats.getAmountFormat(AmountFormatQueryBuilder.of(Locale.US).set(CurrencyStyle.NAME).set("pattern", "00000.00 ยค").build()); + String customFormatted = customFormat.format(oneDolar); + + assertEquals("USD 1", oneDolar.toString()); + assertNotNull(formatUSD); + assertNotNull(customFormat); + assertEquals("USD1.00", usFormatted); + assertEquals("00001.00 US Dollar", customFormatted); } - + @Test - public void givenFormatIsCorrect(){ - JavaMoney j9m; - j9m = new JavaMoney(); - assertEquals("USD1.00", j9m.usFormatted); - assertEquals("00001.00 US Dollar", j9m.customFormatted); - } - - @Test - public void givenConversionIsNotNull(){ - JavaMoney j9m; - j9m = new JavaMoney(); - assertNotNull(MonetaryConversions.getConversion(ConversionQueryBuilder.of().setTermCurrency("EUR").build())); - assertNotNull(MonetaryConversions.getConversion(ConversionQueryBuilder.of().setTermCurrency("USD").build())); - assertNotNull(j9m.convertedAmountEURtoUSD); - assertNotNull(j9m.convertedAmountEURtoUSD2); - assertNotNull(j9m.convertedAmountUSDtoEUR); - assertNotNull(j9m.convertedAmountUSDtoEUR2); + public void givenAmount_whenConversion_thenNotNull() { + CurrencyUnit USD = Monetary.getCurrency("USD"); + MonetaryAmount oneDolar = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(1).create(); + MonetaryAmount fstAmtEUR = Monetary.getDefaultAmountFactory().setCurrency("EUR").setNumber(1.30473908).create(); + + CurrencyConversion convEUR = MonetaryConversions.getConversion(ConversionQueryBuilder.of().setTermCurrency("EUR").build()); + CurrencyConversion convUSD = MonetaryConversions.getConversion(ConversionQueryBuilder.of().setTermCurrency(USD).build()); + + CurrencyConversion conversionUSD = MonetaryConversions.getConversion("USD"); + CurrencyConversion conversionEUR = MonetaryConversions.getConversion("EUR"); + + MonetaryAmount convertedAmountEURtoUSD = fstAmtEUR.with(conversionUSD); + MonetaryAmount convertedAmountEURtoUSD2 = fstAmtEUR.with(convUSD); + MonetaryAmount convertedAmountUSDtoEUR = oneDolar.with(conversionEUR); + MonetaryAmount convertedAmountUSDtoEUR2 = oneDolar.with(convEUR); + + assertEquals("USD", USD.toString()); + assertEquals("USD 1", oneDolar.toString()); + assertEquals("EUR 1.30473908", fstAmtEUR.toString()); + assertNotNull(convEUR); + assertNotNull(convUSD); + assertNotNull(convertedAmountEURtoUSD); + assertNotNull(convertedAmountEURtoUSD2); + assertNotNull(convertedAmountUSDtoEUR); + assertNotNull(convertedAmountUSDtoEUR2); } } From 8ffc21e8cf42bcbd4e9dfaa7111d955159cfad1d Mon Sep 17 00:00:00 2001 From: slavisa-baeldung Date: Fri, 3 Mar 2017 06:57:03 +0100 Subject: [PATCH 4/4] BAEL - 606 - Tests for JSR 354 Money implementation --- .../com/baeldung/money/JavaMoneyTest.java | 69 ++++++++----------- 1 file changed, 27 insertions(+), 42 deletions(-) diff --git a/core-java/src/test/java/com/baeldung/money/JavaMoneyTest.java b/core-java/src/test/java/com/baeldung/money/JavaMoneyTest.java index ed737c6184..7ef4dceccb 100644 --- a/core-java/src/test/java/com/baeldung/money/JavaMoneyTest.java +++ b/core-java/src/test/java/com/baeldung/money/JavaMoneyTest.java @@ -1,13 +1,9 @@ package com.baeldung.money; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.math.BigDecimal; -import java.util.Locale; +import org.javamoney.moneta.FastMoney; +import org.javamoney.moneta.Money; +import org.javamoney.moneta.format.CurrencyStyle; +import org.junit.Test; import javax.money.CurrencyUnit; import javax.money.Monetary; @@ -19,43 +15,36 @@ import javax.money.convert.MonetaryConversions; import javax.money.format.AmountFormatQueryBuilder; import javax.money.format.MonetaryAmountFormat; import javax.money.format.MonetaryFormats; +import java.util.Locale; -import org.javamoney.moneta.FastMoney; -import org.javamoney.moneta.Money; -import org.javamoney.moneta.format.CurrencyStyle; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; +import static org.junit.Assert.*; public class JavaMoneyTest { - @Rule - public ExpectedException thrown = ExpectedException.none(); @Test public void givenCurrencyCode_whenString_thanExist() { - CurrencyUnit USD = Monetary.getCurrency("USD"); - assertNotNull(USD); - assertEquals(USD.getCurrencyCode(), "USD"); - assertEquals(USD.getNumericCode(), 840); - assertEquals(USD.getDefaultFractionDigits(), 2); + CurrencyUnit usd = Monetary.getCurrency("USD"); + + assertNotNull(usd); + assertEquals(usd.getCurrencyCode(), "USD"); + assertEquals(usd.getNumericCode(), 840); + assertEquals(usd.getDefaultFractionDigits(), 2); assertFalse(Monetary.isCurrencyAvailable("AAA")); - } - @Test + @Test(expected = UnknownCurrencyException.class) public void givenCurrencyCode_whenNoExist_thanThrowsError() { - thrown.expect(UnknownCurrencyException.class); - CurrencyUnit AAA = Monetary.getCurrency("AAA"); - assertNull(AAA); - throw new UnknownCurrencyException("AAA"); + CurrencyUnit aaa = Monetary.getCurrency("AAA"); + fail(); // if no exception } @Test - public void givenAmounts_whenStrinfied_thanEquals() { + public void givenAmounts_whenStringified_thanEquals() { CurrencyUnit USD = Monetary.getCurrency("USD"); MonetaryAmount fstAmtUSD = Monetary.getDefaultAmountFactory().setCurrency(USD).setNumber(200.50).create(); MonetaryAmount fstAmtEUR = Monetary.getDefaultAmountFactory().setCurrency("EUR").setNumber(1.30473908).create(); MonetaryAmount oneDolar = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(1).create(); + Money moneyof = Money.of(12, USD); FastMoney fastmoneyof = FastMoney.of(2, USD); Money oneEuro = Money.of(1, "EUR"); @@ -67,30 +56,26 @@ public class JavaMoneyTest { assertEquals("EUR 1.30473908", fstAmtEUR.toString()); assertEquals("USD 12", moneyof.toString()); assertEquals("USD 2.00000", fastmoneyof.toString()); - } @Test public void givenCurrencies_whenCompared_thanNotequal() { MonetaryAmount oneDolar = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(1).create(); Money oneEuro = Money.of(1, "EUR"); + assertFalse(oneEuro.equals(FastMoney.of(1, "EUR"))); assertTrue(oneDolar.equals(Money.of(1, "USD"))); - } - @Test + @Test(expected = ArithmeticException.class) public void givenAmount_whenDivided_thanThrowsException() { MonetaryAmount oneDolar = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(1).create(); - thrown.expect(ArithmeticException.class); - MonetaryAmount oneDivThree = oneDolar.divide(3); - assertNull(oneDivThree); - throw new ArithmeticException(); - + oneDolar.divide(3); + fail(); // if no exception } @Test - public void givenArithmetic_whenStrinfied_thanEqualsAmount() { + public void givenArithmetic_whenStringified_thanEqualsAmount() { CurrencyUnit USD = Monetary.getCurrency("USD"); Money moneyof = Money.of(12, USD); MonetaryAmount fstAmtUSD = Monetary.getDefaultAmountFactory().setCurrency(USD).setNumber(200.50).create(); @@ -100,11 +85,11 @@ public class JavaMoneyTest { MonetaryAmount oneDolar = Monetary.getDefaultAmountFactory().setCurrency("USD").setNumber(1).create(); MonetaryAmount multiplyAmount = oneDolar.multiply(0.25); MonetaryAmount divideAmount = oneDolar.divide(0.25); - - MonetaryAmount[] monetaryAmounts = new MonetaryAmount[] { + + MonetaryAmount[] monetaryAmounts = new MonetaryAmount[]{ Money.of(100, "CHF"), Money.of(10.20, "CHF"), - Money.of(1.15, "CHF"), }; + Money.of(1.15, "CHF"),}; Money sumAmtCHF = Money.of(0, "CHF"); @@ -158,12 +143,12 @@ public class JavaMoneyTest { CurrencyConversion conversionUSD = MonetaryConversions.getConversion("USD"); CurrencyConversion conversionEUR = MonetaryConversions.getConversion("EUR"); - + MonetaryAmount convertedAmountEURtoUSD = fstAmtEUR.with(conversionUSD); MonetaryAmount convertedAmountEURtoUSD2 = fstAmtEUR.with(convUSD); MonetaryAmount convertedAmountUSDtoEUR = oneDolar.with(conversionEUR); MonetaryAmount convertedAmountUSDtoEUR2 = oneDolar.with(convEUR); - + assertEquals("USD", USD.toString()); assertEquals("USD 1", oneDolar.toString()); assertEquals("EUR 1.30473908", fstAmtEUR.toString());