Search in sources :

Example 1 with FastMoney

use of org.javamoney.moneta.FastMoney in project tutorials by eugenp.

the class JavaMoneyUnitManualTest method givenAmounts_whenStringified_thanEquals.

@Test
public void givenAmounts_whenStringified_thanEquals() {
    CurrencyUnit usd = Monetary.getCurrency("USD");
    MonetaryAmount fstAmtUSD = Monetary.getDefaultAmountFactory().setCurrency(usd).setNumber(200).create();
    Money moneyof = Money.of(12, usd);
    FastMoney fastmoneyof = FastMoney.of(2, usd);
    assertEquals("USD", usd.toString());
    assertEquals("USD 200", fstAmtUSD.toString());
    assertEquals("USD 12", moneyof.toString());
    assertEquals("USD 2.00000", fastmoneyof.toString());
}
Also used : FastMoney(org.javamoney.moneta.FastMoney) Money(org.javamoney.moneta.Money) CurrencyUnit(javax.money.CurrencyUnit) MonetaryAmount(javax.money.MonetaryAmount) FastMoney(org.javamoney.moneta.FastMoney) Test(org.junit.Test)

Aggregations

CurrencyUnit (javax.money.CurrencyUnit)1 MonetaryAmount (javax.money.MonetaryAmount)1 FastMoney (org.javamoney.moneta.FastMoney)1 Money (org.javamoney.moneta.Money)1 Test (org.junit.Test)1