@Test public void testToSymbolicAmount_uBTC_uXBT() throws Exception { BitcoinSymbol bitcoinSymbol = BitcoinSymbol.UBTC; Coin localAmount1 = Coin.parseCoin("20999999.12345678"); BigDecimal expected1 = new BigDecimal("20999999123456.78"); BigDecimal actual1 = Coins.toSymbolicAmount(localAmount1, bitcoinSymbol); assertThat(actual1).isEqualTo(expected1); Coin localAmount2 = Coin.parseCoin("0.12345678"); BigDecimal expected2 = new BigDecimal("123456.78"); BigDecimal actual2 = Coins.toSymbolicAmount(localAmount2, bitcoinSymbol); assertThat(actual2).isEqualTo(expected2); Coin localAmount3 = Coin.parseCoin("0.00000001"); BigDecimal expected3 = new BigDecimal("0.01"); BigDecimal actual3 = Coins.toSymbolicAmount(localAmount3, bitcoinSymbol); assertThat(actual3).isEqualTo(expected3); }
public static BigDecimal toSymbolicAmount(Coin coin, BitcoinSymbol bitcoinSymbol) { Preconditions.checkNotNull(coin, "'coin' must be present"); String plainString = coin.toPlainString(); BigDecimal symbolicAmount = new BigDecimal(plainString) .setScale(BITCOIN_SCALE) .multiply(bitcoinSymbol.multiplier()); return symbolicAmount.setScale(bitcoinSymbol.decimalPlaces()); }
Coins { public static BigDecimal toSymbolicAmount(Coin coin, BitcoinSymbol bitcoinSymbol) { Preconditions.checkNotNull(coin, "'coin' must be present"); String plainString = coin.toPlainString(); BigDecimal symbolicAmount = new BigDecimal(plainString) .setScale(BITCOIN_SCALE) .multiply(bitcoinSymbol.multiplier()); return symbolicAmount.setScale(bitcoinSymbol.decimalPlaces()); } }
Coins { public static BigDecimal toSymbolicAmount(Coin coin, BitcoinSymbol bitcoinSymbol) { Preconditions.checkNotNull(coin, "'coin' must be present"); String plainString = coin.toPlainString(); BigDecimal symbolicAmount = new BigDecimal(plainString) .setScale(BITCOIN_SCALE) .multiply(bitcoinSymbol.multiplier()); return symbolicAmount.setScale(bitcoinSymbol.decimalPlaces()); }  }
Coins { public static BigDecimal toSymbolicAmount(Coin coin, BitcoinSymbol bitcoinSymbol) { Preconditions.checkNotNull(coin, "'coin' must be present"); String plainString = coin.toPlainString(); BigDecimal symbolicAmount = new BigDecimal(plainString) .setScale(BITCOIN_SCALE) .multiply(bitcoinSymbol.multiplier()); return symbolicAmount.setScale(bitcoinSymbol.decimalPlaces()); }  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 BigDecimal toSymbolicAmount(Coin coin, BitcoinSymbol bitcoinSymbol) { Preconditions.checkNotNull(coin, "'coin' must be present"); String plainString = coin.toPlainString(); BigDecimal symbolicAmount = new BigDecimal(plainString) .setScale(BITCOIN_SCALE) .multiply(bitcoinSymbol.multiplier()); return symbolicAmount.setScale(bitcoinSymbol.decimalPlaces()); }  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; }