@Test public void testParseFiatInexact() { assertEquals(10000, Fiat.parseFiatInexact("EUR", "0.0001").value); assertEquals(11000, Fiat.parseFiatInexact("EUR", "0.00011").value); }
public static Fiat parseFiatInexact(final String currencyCode, final String str) { try { long val = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).longValue(); return Fiat.valueOf(currencyCode, val); } catch (ArithmeticException e) { throw new IllegalArgumentException(e); } }
Fiat implements Monetary, Comparable<Fiat>, Serializable { public static Fiat parseFiatInexact(final String currencyCode, final String str) { try { long val = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).longValue(); return Fiat.valueOf(currencyCode, val); } catch (ArithmeticException e) { throw new IllegalArgumentException(e); } } }
Fiat implements Monetary, Comparable<Fiat>, Serializable { public static Fiat parseFiatInexact(final String currencyCode, final String str) { try { long val = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).longValue(); return Fiat.valueOf(currencyCode, val); } catch (ArithmeticException e) { throw new IllegalArgumentException(e); } } private  Fiat(final String currencyCode, final long value); }
Fiat implements Monetary, Comparable<Fiat>, Serializable { public static Fiat parseFiatInexact(final String currencyCode, final String str) { try { long val = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).longValue(); return Fiat.valueOf(currencyCode, val); } catch (ArithmeticException e) { throw new IllegalArgumentException(e); } } private  Fiat(final String currencyCode, final long value); static Fiat valueOf(final String currencyCode, final long value); @Override int smallestUnitExponent(); @Override long getValue(); String getCurrencyCode(); static Fiat parseFiat(final String currencyCode, final String str); static Fiat parseFiatInexact(final String currencyCode, final String str); Fiat add(final Fiat value); Fiat subtract(final Fiat value); Fiat multiply(final long factor); Fiat divide(final long divisor); Fiat[] divideAndRemainder(final long divisor); long divide(final Fiat divisor); boolean isPositive(); boolean isNegative(); boolean isZero(); boolean isGreaterThan(Fiat other); boolean isLessThan(Fiat other); @Override int signum(); Fiat negate(); long longValue(); String toFriendlyString(); String toPlainString(); @Override String toString(); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(final Fiat other); }
Fiat implements Monetary, Comparable<Fiat>, Serializable { public static Fiat parseFiatInexact(final String currencyCode, final String str) { try { long val = new BigDecimal(str).movePointRight(SMALLEST_UNIT_EXPONENT).longValue(); return Fiat.valueOf(currencyCode, val); } catch (ArithmeticException e) { throw new IllegalArgumentException(e); } } private  Fiat(final String currencyCode, final long value); static Fiat valueOf(final String currencyCode, final long value); @Override int smallestUnitExponent(); @Override long getValue(); String getCurrencyCode(); static Fiat parseFiat(final String currencyCode, final String str); static Fiat parseFiatInexact(final String currencyCode, final String str); Fiat add(final Fiat value); Fiat subtract(final Fiat value); Fiat multiply(final long factor); Fiat divide(final long divisor); Fiat[] divideAndRemainder(final long divisor); long divide(final Fiat divisor); boolean isPositive(); boolean isNegative(); boolean isZero(); boolean isGreaterThan(Fiat other); boolean isLessThan(Fiat other); @Override int signum(); Fiat negate(); long longValue(); String toFriendlyString(); String toPlainString(); @Override String toString(); @Override boolean equals(final Object o); @Override int hashCode(); @Override int compareTo(final Fiat other); static final int SMALLEST_UNIT_EXPONENT; final long value; final String currencyCode; }