@Test public void testFromLocalAmount() throws Exception { BigDecimal localAmount1 = new BigDecimal("20999999123.456780000000"); Coin expected1 = testAmounts[0]; Coin actual1 = Coins.fromLocalAmount(localAmount1, exchangeRate); assertThat(actual1).isEqualTo(expected1); BigDecimal localAmount2 = new BigDecimal("123.456780000000"); Coin expected2 = testAmounts[1]; Coin actual2 = Coins.fromLocalAmount(localAmount2, exchangeRate); assertThat(actual2).isEqualTo(expected2); BigDecimal localAmount3 = new BigDecimal("0.000010000000"); Coin expected3 = testAmounts[2]; Coin actual3 = Coins.fromLocalAmount(localAmount3, exchangeRate); assertThat(actual3).isEqualTo(expected3); }
public static Coin fromLocalAmount(BigDecimal localAmount, BigDecimal exchangeRate) { Preconditions.checkNotNull(localAmount, "'localAmount' must be present"); Preconditions.checkNotNull(exchangeRate, "'exchangeRate' must be present"); BigDecimal bitcoinAmount = localAmount .setScale(BITCOIN_SCALE) .divide(exchangeRate, BITCOIN_SCALE, RoundingMode.HALF_EVEN) .setScale(8, RoundingMode.HALF_EVEN); return Coin.parseCoin(bitcoinAmount.toPlainString()); }
Coins { public static Coin fromLocalAmount(BigDecimal localAmount, BigDecimal exchangeRate) { Preconditions.checkNotNull(localAmount, "'localAmount' must be present"); Preconditions.checkNotNull(exchangeRate, "'exchangeRate' must be present"); BigDecimal bitcoinAmount = localAmount .setScale(BITCOIN_SCALE) .divide(exchangeRate, BITCOIN_SCALE, RoundingMode.HALF_EVEN) .setScale(8, RoundingMode.HALF_EVEN); return Coin.parseCoin(bitcoinAmount.toPlainString()); } }
Coins { public static Coin fromLocalAmount(BigDecimal localAmount, BigDecimal exchangeRate) { Preconditions.checkNotNull(localAmount, "'localAmount' must be present"); Preconditions.checkNotNull(exchangeRate, "'exchangeRate' must be present"); BigDecimal bitcoinAmount = localAmount .setScale(BITCOIN_SCALE) .divide(exchangeRate, BITCOIN_SCALE, RoundingMode.HALF_EVEN) .setScale(8, RoundingMode.HALF_EVEN); return Coin.parseCoin(bitcoinAmount.toPlainString()); }  }
Coins { public static Coin fromLocalAmount(BigDecimal localAmount, BigDecimal exchangeRate) { Preconditions.checkNotNull(localAmount, "'localAmount' must be present"); Preconditions.checkNotNull(exchangeRate, "'exchangeRate' must be present"); BigDecimal bitcoinAmount = localAmount .setScale(BITCOIN_SCALE) .divide(exchangeRate, BITCOIN_SCALE, RoundingMode.HALF_EVEN) .setScale(8, RoundingMode.HALF_EVEN); return Coin.parseCoin(bitcoinAmount.toPlainString()); }  static BigDecimal toLocalAmount(Coin coin, BigDecimal exchangeRate); static Coin fromLocalAmount(BigDecimal localAmount, BigDecimal exchangeRate); static Coin fromPlainAmount(BigDecimal plainAmount); static Coin fromPlainAmount(String plainAmount); static Coin fromSymbolicAmount(BigDecimal symbolicAmount, BitcoinSymbol bitcoinSymbol); static BigDecimal toSymbolicAmount(Coin coin, BitcoinSymbol bitcoinSymbol); }
Coins { public static Coin fromLocalAmount(BigDecimal localAmount, BigDecimal exchangeRate) { Preconditions.checkNotNull(localAmount, "'localAmount' must be present"); Preconditions.checkNotNull(exchangeRate, "'exchangeRate' must be present"); BigDecimal bitcoinAmount = localAmount .setScale(BITCOIN_SCALE) .divide(exchangeRate, BITCOIN_SCALE, RoundingMode.HALF_EVEN) .setScale(8, RoundingMode.HALF_EVEN); return Coin.parseCoin(bitcoinAmount.toPlainString()); }  static BigDecimal toLocalAmount(Coin coin, BigDecimal exchangeRate); static Coin fromLocalAmount(BigDecimal localAmount, BigDecimal exchangeRate); static Coin fromPlainAmount(BigDecimal plainAmount); static Coin fromPlainAmount(String plainAmount); static Coin fromSymbolicAmount(BigDecimal symbolicAmount, BitcoinSymbol bitcoinSymbol); static BigDecimal toSymbolicAmount(Coin coin, BitcoinSymbol bitcoinSymbol); static final BigDecimal BTC_COIN; }