Same change for Fiat.parseCoin

This commit is contained in:
Mike Hearn
2014-11-14 16:52:09 +01:00
parent 683c50b3fa
commit 20955814bb

View File

@@ -81,8 +81,13 @@ public final class Fiat implements Monetary, Comparable<Fiat>, Serializable {
* if you try to specify fractional satoshis, or a value out of range.
*/
public static Fiat parseFiat(final String currencyCode, final String str) {
return Fiat.valueOf(currencyCode, new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT)
.toBigIntegerExact().longValue());
try {
long val = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT)
.toBigIntegerExact().longValue();
return Fiat.valueOf(currencyCode, val);
} catch (ArithmeticException e) {
throw new IllegalArgumentException(e);
}
}
public Fiat add(final Fiat value) {