You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been developing such a "money" module myself but I was nowhere close to the joda-money solution when I found out about it. Thanks and congrats for this very nice library.
Now, what would be nice to see in the library (in my opinion) is a more elaborate way to convert money instances between different currency units.
I think I could provide an initial version of such a utility class. I think it would supplement the money functionality that the library already provides.
The thing I propose is an object having the following functionality - I present it here as an interface, I have it implemented as a class.
class ExchangeRate {
// Converts the given money to the monetary amount in this rates other currency.
Money exchange(Money toExchange);
// Combines to exchange rates together that have a common currency units
ExchangeRate combine(ExchangeRate other);
}
An instance of exchange rate is something that represents the following "equasion": 1 unit of target currency = n units of source currency.
An example would be:
1 EUR = 1.3 USD
A user can pass either an amount in EUR or USD to get an equivalent Money instance in the other currency.
The combine operation would allow the user to get a cross exchange rate. If one has the following exchange rates:
1 EUR = 1.3 USD
1 GBP = 1.55 USD
than a combination of the first and second would result in the following rate:
1 EUR = 0.838710 GBP.
The convertedTo method on Money object could internally construct an instance of ExchangeRate and use the conversion logic.
I don't have the fancy ;-) from String parsing methods nor any special formatters for it but I think it would be a good start.
Tell me what you think about it.
The text was updated successfully, but these errors were encountered:
I think that some kind of exchange rate interface probably makes sense in an API like this. It will need to be simple and unobtrusive, as different domains have very different demands on what they need from such a conversion. I suspect that the combining of rates is probably more complex than is needed, and that should be up to the application for example.
If you want to propose something, you could fork GitHub and try something out....
From https://sourceforge.net/u/tompasik/profile/
https://sourceforge.net/p/joda-money/feature-requests/2/
I've been developing such a "money" module myself but I was nowhere close to the joda-money solution when I found out about it. Thanks and congrats for this very nice library.
Now, what would be nice to see in the library (in my opinion) is a more elaborate way to convert money instances between different currency units.
I think I could provide an initial version of such a utility class. I think it would supplement the money functionality that the library already provides.
The thing I propose is an object having the following functionality - I present it here as an interface, I have it implemented as a class.
class ExchangeRate {
// Converts the given money to the monetary amount in this rates other currency.
Money exchange(Money toExchange);
// Combines to exchange rates together that have a common currency units
ExchangeRate combine(ExchangeRate other);
}
An instance of exchange rate is something that represents the following "equasion": 1 unit of target currency = n units of source currency.
An example would be:
1 EUR = 1.3 USD
A user can pass either an amount in EUR or USD to get an equivalent Money instance in the other currency.
The combine operation would allow the user to get a cross exchange rate. If one has the following exchange rates:
1 EUR = 1.3 USD
1 GBP = 1.55 USD
than a combination of the first and second would result in the following rate:
1 EUR = 0.838710 GBP.
The convertedTo method on Money object could internally construct an instance of ExchangeRate and use the conversion logic.
I don't have the fancy ;-) from String parsing methods nor any special formatters for it but I think it would be a good start.
Tell me what you think about it.
The text was updated successfully, but these errors were encountered: