CurrencyEditText icon indicating copy to clipboard operation
CurrencyEditText copied to clipboard

Many problems using the module internationally. Perhaps I am doing something wrong

Open StainlessStlRat opened this issue 2 months ago • 0 comments

I will list out my problems here:

  1. I am trying to store the values without losing any data. For US currency for example, that means storing in "cents" not "dollars". There is no easy way of getting the value out except as a double, which means multiplying by 100 and possibly losing a cent due to precision issues.
  2. I have no way of knowing when the currency does not have cents. Like the South African Rand. In these cases, the division is unnecessary.
  3. Even if I use the "getString()" method, drop all non numeric values to get the Long value, there is no convenient method of then setting this value back. So if I have cents, I need to format the string myself. This presents two problems all in itself. If I explicitly format, then I'll lose the currencies dividing symbol (though I suppose I can query for that from the module), as well as doing unnecessary formatting for the currencies that don't have cent values. So R448 would become R448,00
  4. I thought my savior would be the "getNumericValue" I saw in the documentation, but this method does not exist.
  5. If you set the locale before setting the text, it crashes.

What I would like to be able to do is get a flat, numeric value from edit text (so it would represent cents in US and full rand/R in South Africa) and to also be able to call editText.setCurrencyValue(numericValue) and have it take care of the rest.

Is any of this possible in the future or am I missing how to do this with what's available already?

StainlessStlRat avatar May 01 '24 20:05 StainlessStlRat